Hello developers! I’m excited to release my slider module, it allows you to create customizable sliders with ease!
Overview
This class allows you to create sliders with minimum lines of code and tons of customizability to fit your needs while staying very beginner friendly! This class supports vertical and horizontal axis as well as “waypoints”, they allow you to create points that you can easily detect when the user enters it, which adds more possibilities to your sliders!
Starting off
You will need to get the model before continuing, a game file is found at the end of the post an example is found inside the module to help you get familiar with the system!
API
Note: Functions that return () will be written as they return nil.
-
🔨 Making A Slider Object 🔨
To create a slider Object, just do:
local Slider = require(path.to.slider.module)
local slider = Slider.new(sliderFrame, properties)
-
sliderFrame is the the object that will become draggable, it must be a GuiObject parented to another GuiObject.
-
properties is a table containing all properties of the slider, check Custom Types section below for more info.
From now on, we will use the slider Object we created for the rest of the API.
-
🔒 Main Methods 🔓
-
slider:Enable()
parameters: widget: PluginGui? (read the Plugin section.)
returns: nil -
slider:Disable()
parameters: nil
returns: nil -
slider:Reset()
parameters: nil
returns: nil
notes: Resets the slider’s position to properties.defaultValue
-
📝 Get Methods 📝
-
slider:GetStep()
parameters: nil
returns: number -
slider:GetValue()
parameters: usePercentage: boolean?
returns: number -
slider:GetValues()
help: Returns the min and max values of the slider.
parameters: nil
returns: values: values
-
🔍 Set Methods 🔍
-
slider:SetPluginMouse()
parameters: plugin: Plugin
returns: nil -
slider:SetStep()
parameters: n: number
returns: nil -
slider:SetValue()
parameters: value: number, isPercentage: boolean?
returns: nil -
slider:SetValues()
help: Sets the min and max values of the slider.
parameters: values: values
returns: nil
-
slider:SetPosition()
parameters: position: UDim2, forced: boolean, frame: GuiObject?
returns: nil
Internal Methods
-
slider:AddWaypoint()
parameters: n: number, isPercentage: boolean?
returns: waypoint, -
slider:RemoveWaypoint()
parameters: n: number
returns: nil -
slider:ShowWaypoint()
parameters: n: number
returns: nil -
slider:HideWaypoint()
parameters: n: number
returns: nil -
slider:ShowWaypoints()
parameters: nil
returns: nil -
slider:HideWaypoints()
parameters: nil
returns: nil
Waypoint Methods
-
slider:AddTracker()
parameters: label: TextLabel, roundFunction: roundFunction?, textMakerFunction: textMakerFunction?
returns: Tracker,-
roundFunction
parameters: n: number
returns: string
optional: yes
default value: utilityFunctions.roundToDecimalPlaces -
textMakerFunction
parameters: _string: string (return ofroundFunction
returns: string (text to be displayed)
optional: yes
default value: a function that returns the string as it is.
-
-
slider:EnableTracker()
parameters: tracker: Tracker
returns: nil -
slider:DisableTracker()
parameters: tracker: Tracker
returns: nil -
slider:EnableTrackers()
parameters: nil
returns: nil -
slider:DisableTrackers()
parameters: nil
returns: nil
Tracker Methods
-
slider.moved:Connect()
parameters: callback(isForced: boolean): -
slider.waypointEntered:Connect()
parameters: callback: (isForced: boolean) → nil):
Signals / Events
Both functions passed to the Connect
method get 1 parameter, isForced, a boolean, stating whether or not the slider was moved using slider:SetValue()
, they return nil
Custom Types
-
🏷️ Properties 🏷️
-
step: number
description: How small or big a user moves per drag
default value: 0.01
optional: yes -
xboxStep: number
description: How small or big a user moves per drag with the Xbox controller
default value: 0.1
optional: yes -
canLeaveFrame: boolean
description: whether or not the slider Frame can leave the parent frame, when set to true, the slider can go outside the frame by half it’s size.
default value: true
optional: yes -
canFullyLeaveFrame: boolean
description: whether or not the slider Frame can completely leave the parent frame, when set to true, the slider can leave it’s parent completely so that the end of the frame touches the start of the slider Frame or the start of the slider Frame touches the end of the parent frame
default value: false
optional: yes -
moveToMouse: boolean
description: Whether or not the slider moves to the mouse even when it’s not hovering it, when set to true, clicking anywhere on the parent slider will move the slider to the mouse’s position.
default value: false
optional: yes -
waypoints: {[number]: waypoint}
description: Holds the waypoints of the slider, no need to mess with it
default value: {}
optional: yes -
trackers: {[number]: tracker}
description: Holds the trackers of the slider, no need to mess with it
default value: {}
optional: yes -
values: {min: number, max: number}
description: Minimum and maximum values of the slider, use inslider:GetValue(false)
.
default value: {min = 0, max = 1}
optional: yes (better to specify) -
defaultValue: number
description: The default position of the slider.
default value: (properties.max + properties.min) / 2
optional: yes -
axis: string
description: The axis in which the slider moves at, X or Y.
default value: X
optional: yes
These types are just made for the ease of use and for code recommendations, check the Slider.types
module for more info.
Plugin
-
Use
slider:SetPluginMouse(plugin)
before callingslider:Enable()
. -
If your using a
DockWidgetPluginGui
then pass an argument toslider:Enable()
,widget
, it’s yourDockWidgetPluginGui
, this allows you to create sliders inDockWidgetPluginGui
s.
Finishing
Any feedback is welcome. If you found any bugs and/or want to recommend features, tell me and I’ll reply as fast as I can!
Hope my slider module will help you in the future, happy developing!
Small preview of the place file above. (Sorry for the bad quality!) (Don’t check as it isn’t updated yet.)
If I had any silly mistakes in the post please inform me!
Updates
V1.1.0
V1.1.1
V1.2.0
V1.2.1
V1.2.2
V2
V2.0.1
V2.0.2
V2.0.3
V2.0.4
V2.0.5
V2.0.6
V2.0.7
- Very likely
- Likely
- Even
- Unlikely
- Very unlikely
0 voters
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
0 voters
- Msix