Slider
A number in a range, with a step size and a unit suffix.
The smallest slider#
main:Slider({
Text = "Walk speed",
Min = 16,
Max = 250,
Callback = function(value)
humanoid.WalkSpeed = value
end,
})Without Default it starts at Min. Without Step it moves in whole numbers.
Preview
My Script
v1.0
Search…
Ember v1Speed
16 studs/s
Building it up#
Set a starting value:
main:Slider({
Text = "Walk speed",
Min = 16, Max = 250, Default = 16,
Callback = setSpeed,
})Show the unit. Suffix is appended to the displayed number:
main:Slider({
Text = "Walk speed",
Min = 16, Max = 250, Default = 16,
Suffix = " studs/s",
Callback = setSpeed,
})Use decimals. Step sets the increment. The readout shows a whole number
as an integer and anything else to two decimals:
main:Slider({
Text = "Aim smoothing",
Min = 0, Max = 1, Default = 0.35,
Step = 0.05,
Callback = function(v) smoothing = v end,
})Every option#
| Option | Type | Default | What it does |
|---|---|---|---|
Textreq | string | — | The label. |
Min | number | 0 | Lowest value. |
Max | number | 100 | Highest value. |
Default | number | Min | Starting value. Clamped into range. |
Step | number | 1 | Increment. Use 0.1 or 0.01 for decimals, or 0 for no snapping. |
Suffix | string | — | Appended to the number: a unit, or a percent sign. |
Callback | function(number) | — | Called as the value changes, including while dragging. |
Description | string | — | A quieter second line. |
Icon | string | — | An icon shown before the label. |
Save | string | boolean | — | Persist under this key. true derives one from the section and label. |
Tooltip | string | — | Shown while the pointer is over the control. |
Disabled | boolean | false | Refuses input and dims the control. |
DisabledReason | string | — | Shown as a tooltip while it is disabled. |
Methods#
| Method | Returns | What it does |
|---|---|---|
Get() | number | The current value |
Set(value) | true, or false, reason | Moves the knob and fires Callback. Clamped into range. |
Callbacks fire while dragging#
The value applies as you move the knob, not when you let go. Calls are coalesced to one per frame with the value that landed last, so a drag can still run your callback sixty times a second.
Cheap work is fine:
Callback = function(v) humanoid.WalkSpeed = v end -- one property writeExpensive work is not. Do the cheap part live and defer the rest:
local pending
main:Slider({
Text = "Render distance",
Min = 100, Max = 5000, Default = 1000,
Callback = function(v)
label:Set(v .. " studs") -- instant feedback
pending = v -- the expensive rebuild happens elsewhere
end,
})You do not need to do this for Save: writes are already debounced. See
Saving settings.