ContextActionService bound actions stop iterating the bind-stack if script who bound the given action is deleted.
This stops other still valid binds bound before it from ever being reached.
You can fix this by manually unbinding it or rebinding the same actionName.
Uploading a place that replicates the problem.
It binds prints to E on keyboard & X on Gamepad.
Comment out OnReset:17 “Actions.Unbind(id - 1)” to trigger the issue.
If you comment out that line and reset the character, the bind “0 - Static” will no longer be reached.
ContextActionService Bind Bug.rbxl (57.0 KB)
Expected behavior
I expect a bound action in a LocalScript under CharacterStarterScripts either to be automatically unbound, remain a valid bind until explicitly unbound, or at least not to break iteration for other still valid binds after respawning character removing the original script. If it “should” break then an error would be nice.
In my test file I expect the first bind “0 - Static” to always be reached even after respawning the character.
This also affects ResetOnSpawn GUIs that have LocalScripts binding inputs.
3 Likes
Hi @Noob_McDev,
Thanks for the report! After reviewing, this occurs because the default behavior for actions is to sink the iteration of the bind stack if Enum.ContextActionResult.Pass is not explicitly returned.
If functionToBind from ContextActionService:BindAction() returns Enum.ContextActionResult.Sink, the input event will stop at that function and no other bound actions under it will be processed. This is the default behavior if functionToBind does not return anything or yields in any way. ContextActionResult | Documentation - Roblox Creator Hub
Since the script that bound the action is deleted and the action becomes invalid, the default behavior occurs when reaching this action which sinks the iteration. We decided this is the intended design, so if you want to preserve iteration after deleting scripts, please explicitly unbind these actions.
Thanks for the reply.
The function is not called to be able to return Enum.ContextActionResult.Pass. Since this fails silently and more importantly affects other code, it would be nice if this was communicated. Either in documentation or output. It took some time to figure out what was happening when this issue occurred. Ideally the script could automatically unbind all actions on deletion (is it ever desirable to not unbind them?), just like connections are disconnected on script deletion.
Feel free to close the thread.