Skip to main content

Binding Keys to other Elements

Creation Snippet

local Bind = Label:AddBind({
HoldToInteract = false,
CurrentValue = "Q",
Callback = function(Value)

end,
}, "INDEX")

This is just a snippet, not all parameters are included
Replace INDEX with a unique identifier of the instance that is not repeated within other nested elements nested in the parent.
Basically, you can just call it the type of nested element since theres only one of these in your label/toggle.

Accepted Parents

Label, Toggle

Parameters

HoldToInteract : boolean NOT REQUIRED
Whether the bind needs to be held to achieve the affect instead of toggling.

CurrentValue : string
The current binded input/key of the well, Bind.
For keys, view the KeyCode Documentation For Roblox.
For Mouse Buttons, its MB1 and MB2.
Can be set to nil.

SyncToggleState : boolean NOT REQUIRED REQUIRES PARENT TO BE TOGGLE
Whether to sync the parent toggle's state and the bind's. Should always be toggled unless you have some niche reason.

Callback : function REQUIRED IS PARENT IS LABEL
The function that executes when the Bind is activated or deactivated.
You do not need to repeat the original Callback if the parent is a toggle, but you can add extra stuff if it is activated by a bind like this.
Passed Parameters:

  • Value : boolean
    The state of the Bind (Active or Not Active).

OnChangedCallback : function
The function that executes when the Bind's CurrentValue is changed.
Passed Parameters:

  • Value : string
    The new Key expressed in a string.

Returns

GuiObject .Instance

  • The actual Instance of the Element within Roblox.

boolean .Active

  • The current state of the Binded Key.