InputAction state is not synchronized unless it is a descendant of InputContext

Reproduction File: Script.rbxm (3.1 KB)

"NonContextAction": {
  "$className": "InputAction",
  "InputBinding": {
    "$className": "InputBinding",
    "$properties": {
      "KeyCode": "Q"
    }
  }
},
"CustomContext": {
  "$className": "InputContext",
  "InputAction": {
    "$className": "InputAction",
    "InputBinding": {
      "$className": "InputBinding",
      "$properties": {
        "KeyCode": "Q"
      }
    }
  }
}
game.Players.PlayerAdded:Connect(function(plr)
	const nonContextAction = script.NonContextAction:Clone()
	
	const customContext = script.CustomContext:Clone()
	const customAction = customContext.InputAction
	
	nonContextAction.StateChanged:Connect(function(state)
		print("NonContext Action State: ", state)
	end)
	
	customAction.StateChanged:Connect(function(state)
		print("Custom Action State: ", state)
	end)
	
	nonContextAction.Parent = plr
	customContext.Parent = plr
end)
  Custom Action State:  true - Script:12
  Custom Action State:  false - Script:12

According to:

β€œ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).”

an InputAction is expected to function correctly on the client even when no InputContext ancestor exists, as it is automatically assigned to a default context.

Currently, on the server, if an InputAction does not have an InputContext ancestor, its state is not synchronized at all. Instead, it should follow the built-in default priority and synchronize its state in the same way as it does on the client.

Expected behavior

  Custom Action State:  true - Script:12
  NonContext Action State:  true - Script:8
  Custom Action State:  false - Script:12
  NonContext Action State:  false - Script:8

Alternatives

If this behavior is intentional rather than a bug, the documentation should explicitly state that InputAction s without an InputContext ancestor do not synchronize their state on the server.

The current documentation implies that such actions are automatically registered to a default context, which makes it reasonable to expect identical behavior between the client and server implementations.

Current:

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

Change:

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 on the client. On the server, an InputContext ancestor is required for state synchronization).

1 Like