I made this OOP-based slider for a 3-row slider RGB colour picker, and since I’ve seen a few topics of people asking how to make a slider, or a colour picker, I decided I’d make it open source.
It supports mouse, touch, and controller input.
The code of the module can be found here (GitHub).
You will need a slider bar/button GuiObject instance to parent to the module, as it does not do the instantiation of it right now. I uploaded the module as a free model with the required GuiObject parented to it here.
The default value range is 0-1, refer to documentation below to see how to change the range.
https://gyazo.com/fd084113974dab76e2712a7a8f81b22d
Documentation
-- arg #1 == new value, arg #2 == old value
local function changed_function(new_val, old_val)
end
-- return value #1 is the OOP slider object
-- return value #2 is the value.Changed event you can connect to if you need to fire multiple functions (if just 1 function, just pass it as argument #1)
-- arg_type, arg_name, default_value
local slider, changed_event = Slider.new(Function changed_function nil, GuiObject Parent nil, Number min 0, Number max 1, Boolean round false)
-- to parent without passing in parameter #2, you'd do this:
slider.Bar.Parent = your_parent
-- to set the slider to a value manually, you'd do this:
slider:Set(value, Boolean tween_slider false)
05/04/2019: updated code with some bug fixes including malfunctioning when slider is resized.