Slider
A number in a range. Drag it, and your callback gets the value.
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.
Live preview
My Script
v1.0
Search…
Main
Visuals
Settings
Speed
16 studs/s
Building it up#
Start somewhere sensible:
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 controls the increment and how the value is shown:
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. |
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 | — | Persist under this key. |
Methods#
| Method | Returns | What it does |
|---|---|---|
Get() | number | The 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:
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,
})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.