ContextActionService callback needs to explicitly return sink enum when bound to PlayerActions to actually sink inputs

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:

  1. Open a baseplate in Studio
  2. Press Play Solo
  3. Paste in command bar:
ContextActionService:BindAction(
    "TestBinding1",
    function()
        -- not explicitly returning anything
    end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)
  1. Try to move your character
  2. Paste in command bar:
ContextActionService:BindAction(
    "TestBinding2",
    function()
        -- now explicitly returning:
        return Enum.ContextActionResult.Sink
    end,
    false,
    unpack(Enum.PlayerActions:GetEnumItems())
)
  1. 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.

5 Likes

Pretty sure this has been patched.