AROYN UI LIBRARY / UI COMPONENTS

Slider

Choose a finite number within bounds and quantize it to a step.

Create Slider#

Choose a finite number within bounds and quantize it to a step.

The constructor returns a Slider handle. The snippet assumes section exists, as created in Quick start.

LUAU
local slider = section:CreateSlider({
    Name = "Volume", Flag = "volume", Min = 0, Max = 100, Step = 5,
    Default = 40, Suffix = "%",
    Callback = function(value) print("Volume:", value) end,
})
Volume Slider in Roblox showing 40% and its thumb on the horizontal track.Open full size ↗
Volume at 40%. The value and thumb are shown together.

Arguments#

OptionTypeDefaultMeaning
Minnumber0Finite lower bound.
Maxnumber100Finite upper bound, at least Min.
Stepnumber1Finite positive interval.
DefaultnumberMinClamped and step-normalized.
Suffixstring""Display suffix, such as %.
Callbackfunction(number)nilReceives the normalized value.

Also accepts common options: Name, Description, Disabled and Callback; stateful controls additionally support Flag, Persist and Sensitive.

Manage state#

LUAU
slider:SetValue(58, true) -- normalized to a step in bounds
print(slider:GetValue())
slider:SetDisabled(true)

Returned methods#

MethodReturnsBehavior
GetValue()numberCurrent number value.
SetValue(value, notify?)selfSilent by default; true calls Callback only after a changed normalized value.
SetDisabled(boolean)selfChanges user availability without discarding the value.
IsDisabled()booleanReads the requested disabled state.
Destroy()nilRemoves this control and its subscriptions; safe to repeat.

Behavior and limitations#

Max must be at least Min; Step must be greater than zero, and (Max-Min)/Step must remain below 1e15. NaN and infinity are rejected.

Modal opening, hide, minimize, disable or destruction cancel an active drag and restore scrolling ownership.

Mouse/touch support exists in the implementation. Real touch behavior is still pending device verification; mock input tests do not establish it.

Steps are rounded to the nearest interval from Min, with halfway values rounding upward. Exact Min and Max remain reachable even when the range is not divisible by Step. An invalid setter asserts before changing the value.