Skip to content

Class · inherits Instance

InputAction

Official docs ↗

Defines a gameplay action mechanic. These actions are then mapped to hardware inputs using InputBinding.

About InputAction

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 4

  • DisplayName: stringLocalized display name for this action.

    A custom string used to show a localized display name for this action in UI elements such as a controls help menu.

  • Enabled: booleanDetermines if the InputAction is enabled or not.

    Determines if the InputAction is enabled or not. The action state will be reset if this property is toggled to false.

  • PreferredBinding: InputBindingReadOnlyNotReplicatedThe InputBinding best matching the player's current input device.

    A read-only reference to the InputBinding child that matches the player's current input device using UserInputService.PreferredInput.

  • Type: InputActionTypeSpecifies what type of input value the action is expecting.

    Specifies what type of input value the action is expecting. See InputActionType for more details.

Methods 1

  • GetState() → VariantReturns the current state of the InputAction.

    Returns the current state of the InputAction, for example true for an action with Type set to Bool.

Events 3

  • PressedInputAction.Pressed:Connect(function())Fires only when the InputAction.Type is set to Bool on a state transition from false to true.

    This event fires only when the Type is set to Bool, and only when the state transitions from false to true.

  • ReleasedInputAction.Released:Connect(function())Fires only when the InputAction.Type is set to Bool on a state transition from true to false.

    This event fires only when the Type is set to Bool, and only when the state transitions from true to false.

  • StateChangedInputAction.StateChanged:Connect(function(value))Fires for all InputActionType types whenever the state changes, except if the state attempts to transition to the same state.

    This event fires for all InputActionType types whenever the state changes, except if the state attempts to transition to the same state.

InputAction also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.