Slider

A number in a range. Drag it, and your callback gets the value.

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.

Live preview

My Script

v1.0

Speed

16 studs/s

Building it up#

Start somewhere sensible:

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

Show the unitSuffix is appended to the displayed number:

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

Use decimalsStep controls the increment and how the value is shown:

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.
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.
SavestringPersist under this key.

Methods#

MethodReturnsWhat it does
Get()numberThe current value
Set(value)Moves the knob and fires Callback

Callbacks fire while dragging#

That is what makes a slider feel live — the value applies as you move it, not when you let go. It also means your callback can run many times per 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,
})

Saving is already debounced

You do not need to do this for Save. Writes are debounced by 0.4 seconds by default, so dragging a saved slider does not hammer the disk. See Saving settings.