When binding a ContextActionService binding that involves PlayerActions, the callback needs to explicitly return Enum.ContextActionResult.Sink to sink the call. This is inconsistent when comparing to callbacks triggered by any other kind of input (keycode/userinputtype/etc), where sinking is assumed if no ContextActionResult is returned.
How to repro:
- Open a baseplate in Studio
- Press Play Solo
- Paste in command bar:
ContextActionService:BindAction(
"TestBinding1",
function()
-- not explicitly returning anything
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
- Try to move your character
- Paste in command bar:
ContextActionService:BindAction(
"TestBinding2",
function()
-- now explicitly returning:
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
- Try to move your character
Observed behavior:
At step 4, surprisingly, you can still move your character.
At step 6, you cannot move your character.
Expected behavior:
When no ContextActionResult is returned, ContextActionService will normally assume that the input is sunk. Run the following example and press F to observe that this is the case:
ContextActionService:BindActionAtPriority(
"BindingToF",
function()
print("this F")
end,
false,
50,
Enum.KeyCode.F
)
ContextActionService:BindActionAtPriority(
"BindingToFOverride",
function()
print("other F")
-- implicitly sinks input even though not returning anything
end,
false,
100,
Enum.KeyCode.F
)
Only “other F” is printed, never “this F”, because the second binding correctly sinks the input as expected.
When the callback is triggered to PlayerActions, it should do just that. If nothing is returned by the callback, it should assume the input should be sunk and not passed on to further callbacks connected to those actions.