Slider

A number in a range, with a step size and a unit suffix.

The smallest slider#

Luau
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

Speed

16 studs/s

Building it up#

Set a starting value:

Luau
main:Slider({
    Text = "Walk speed",
    Min = 16, Max = 250, Default = 16,
    Callback = setSpeed,
})

Show the unit. Suffix is appended to the displayed number:

Luau
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:

Luau
main:Slider({
    Text = "Aim smoothing",
    Min = 0, Max = 1, Default = 0.35,
    Step = 0.05,
    Callback = function(v) smoothing = v end,
})

Every option#

OptionTypeDefaultWhat it does
TextreqstringThe label.
Minnumber0Lowest value.
Maxnumber100Highest value.
DefaultnumberMinStarting value. Clamped into range.
Stepnumber1Increment. Use 0.1 or 0.01 for decimals, or 0 for no snapping.
SuffixstringAppended to the number: a unit, or a percent sign.
Callbackfunction(number)Called as the value changes, including while dragging.
DescriptionstringA quieter second line.
IconstringAn icon shown before the label.
Savestring | booleanPersist under this key. true derives one from the section and label.
TooltipstringShown while the pointer is over the control.
DisabledbooleanfalseRefuses input and dims the control.
DisabledReasonstringShown as a tooltip while it is disabled.

Methods#

MethodReturnsWhat it does
Get()numberThe current value
Set(value)true, or false, reasonMoves 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:

Luau
Callback = function(v) humanoid.WalkSpeed = v end     -- one property write

Expensive work is not. Do the cheap part live and defer the rest:

Luau
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.