Class
InputAction
Defines a gameplay action mechanic. These actions are then mapped to hardware
inputs using InputBinding.
InputAction defines a gameplay action mechanic such as "Jump," "Sprint," or
"Shoot." These actions are then mapped to hardware inputs using
InputBinding. An InputAction will check for its first ancestor type
of InputContext and register itself to that context (if there is no
ancestor context, it will be registered to a default context).
Properties 9#
BoolStateboolean | Non-scriptable read-only property useful for debugging
Bool input actions.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicatedNotScriptable |
Direction1DStatefloat | Non-scriptable read-only property useful for debugging
Direction1D input actions.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicatedNotScriptable |
Direction2DStateVector2 | Non-scriptable read-only property useful for debugging
Direction2D input actions.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicatedNotScriptable |
Direction3DStateVector3 | Non-scriptable read-only property useful for debugging
Direction3D input actions.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicatedNotScriptable |
DisplayNamestring | Localized display name for this action.ReadSafe |
Enabledboolean | Determines if the InputAction is enabled or not.ReadSafe |
PreferredBindingInputBinding | The InputBinding best matching the player's current input device.ReadSafeReadOnlyNotReplicated |
TypeInputActionType | Specifies what type of input value the action is expecting.ReadSafe |
ViewportPositionStateVector2 | Non-scriptable read-only property useful for debugging
ViewportPosition input actions.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafeReadOnlyNotReplicatedNotScriptable |
BoolState: boolean#
ReadOnlyNotReplicatedNotScriptableRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
Direction1DState: float#
ReadOnlyNotReplicatedNotScriptableRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
A non-scriptable read-only property only visible in Studio, primarily
useful for debugging while testing an InputAction with
Type of Direction1D.
Direction2DState: Vector2#
ReadOnlyNotReplicatedNotScriptableRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
A non-scriptable read-only property only visible in Studio, primarily
useful for debugging while testing an InputAction with
Type of Direction2D.
Direction3DState: Vector3#
ReadOnlyNotReplicatedNotScriptableRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
A non-scriptable read-only property only visible in Studio, primarily
useful for debugging while testing an InputAction with
Type of Direction3D.
DisplayName: string#
ReadSafe
A custom string used to show a localized display name for this action in UI elements such as a controls help menu.
Enabled: boolean#
ReadSafe
Determines if the InputAction is enabled or not. The action state will
be reset if this property is toggled to false.
PreferredBinding: InputBinding#
ReadOnlyNotReplicatedReadSafe
A read-only reference to the InputBinding child that matches the
player's current input device using
UserInputService.PreferredInput.
Type: InputActionType#
ReadSafe
Specifies what type of input value the action is expecting. See
InputActionType for more details.
ViewportPositionState: Vector2#
ReadOnlyNotReplicatedNotScriptableRead: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe
A non-scriptable read-only property only visible in Studio, primarily
useful for debugging while testing an InputAction with
Type of ViewportPosition.
Methods 2#
| Fire | Updates the InputAction to the given state and fires the appropriate
signals.Deprecated |
| GetState | Returns the current state of the InputAction.Safe |
Fire(state: Variant): ()#
DeprecatedDeprecated
Deprecated. Use InputBinding:Fire() with a Scriptable
binding instead.
Updates the InputAction to the given state and fires the appropriate
signals. This method is most useful for script‑triggered "input" where the
passed state should trigger events like
Pressed or
StateChanged regardless of whether the
player triggered that state through normal inputs.
This method will only accept a state parameter that matches the
Type and attempting to call it with a mismatched
type will cause an error, for example passing a state of 0.5 when the
Type is Bool.
Note that this method follows the conditions of
Pressed,
Released, and
StateChanged. For example, if you make
multiple consecutive calls to Fire() with a state of true,
StateChanged will only fire on the first
state change and the subsequent calls to Fire() will do nothing.
| Name | Type | Default | Description |
|---|---|---|---|
state | Variant |
Returns
()
GetState(): Variant#
Safe
Returns the current state of the InputAction, for example true
for an action with Type set to
Bool.
Returns
Variant— The current state ofInputAction.
Events 3#
| Pressed | Fires only when the InputAction.Type is set to
Bool on a state transition from false to true. |
| Released | Fires only when the InputAction.Type is set to
Bool on a state transition from true to false. |
| StateChanged | Fires for all InputActionType types whenever the state changes,
except if the state attempts to transition to the same state. |
Pressed()#
Released()#
StateChanged(value: Variant)#
This event fires for all InputActionType types whenever the state
changes, except if the state attempts to transition to the same state.
| Name | Type | Default | Description |
|---|---|---|---|
value | Variant | The new state of the InputAction. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild