InputAction

Show Deprecated
Not Browsable

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).

Summary

Properties

  • Read Only
    Not Replicated
    Not Scriptable
    Roblox Script Security
    Read Parallel
  • Read Only
    Not Replicated
    Not Scriptable
    Roblox Script Security
    Read Parallel

    Non-scriptable read-only property useful for debugging Direction1D input actions.

  • Read Only
    Not Replicated
    Not Scriptable
    Roblox Script Security
    Read Parallel

    Non-scriptable read-only property useful for debugging Direction2D input actions.

  • Read Only
    Not Replicated
    Not Scriptable
    Roblox Script Security
    Read Parallel

    Non-scriptable read-only property useful for debugging Direction3D input actions.

  • Read Parallel

    Determines if the InputAction is enabled or not.

  • Specifies what type of input value the action is expecting.

Methods

  • Fire(state : Variant):()

    Updates the InputAction to the given state and fires the appropriate signals.

  • GetState():Variant

    Returns the current state of the InputAction.

Events

Properties

BoolState

Read Only
Not Replicated
Not Scriptable
Roblox Script Security
Read Parallel

Direction1DState

Read Only
Not Replicated
Not Scriptable
Roblox Script Security
Read Parallel

A non-scriptable read-only property only visible in Studio, primarily useful for debugging while testing an InputAction with Type of Direction1D.

Direction2DState

Read Only
Not Replicated
Not Scriptable
Roblox Script Security
Read Parallel

A non-scriptable read-only property only visible in Studio, primarily useful for debugging while testing an InputAction with Type of Direction2D.

Direction3DState

Read Only
Not Replicated
Not Scriptable
Roblox Script Security
Read Parallel

A non-scriptable read-only property only visible in Studio, primarily useful for debugging while testing an InputAction with Type of Direction3D.

Enabled

Read Parallel

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

Read Parallel

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

Methods

Fire

()

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.

Parameters

state: Variant
Default Value: ""

Returns

()

GetState

Variant

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


Returns

Variant

The current state of InputAction.

Events

Pressed

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


Released

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


StateChanged

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

Parameters

value: Variant

The new state of the InputAction.