Context action service question

Lets say I bind action1 to the left mouse button. If I bind action2 to the left mouse button, but do NOT unbind action1, does it overwrite action1 and still work as you’d expect?

No, context bindings are stackable. If you bind two actions to LMB they will both execute if you pass the according input. The only case where this doesn’t happen is if a higher priority input returns the Sink ContextActionResult which will prevent bindings at a lower priority from executing.

Regarding the sink behaviour as an ELI5: suppose you have four actions at priorities 1, 6, 200 and 700. 200 returns the Sink result. 200 and 700 will run, 1 and 6 will not.

1 Like

This question could be answered with a quick google search of the API page: ContextActionService:BindAction. The most recently bound action takes priority, then other functions will run after it in descending priority order.

1 Like

ok well in that case, is there any way i can just unbind whatever is bound to the lmb? because sometimes i wont know what is bound to it

or what if i just unbind all possible actions? or will that error, since only one of them is actually bound

Why will you not know what’s bound to LMB? You should predictably know what action bindings will be created in your experience. There’s a fundamental design or technical flaw if you’re expecting unexpected bindings. Even accepting arbitrary bindings such as in the case of key rebinding features can still be tracked.

You can inspect active bindings with GetAllBoundActionInfo and do a clean wipe of context bindings with UnbindAllActions (make sure to search documentation first in the future). Likewise in the case of binding, you should predictably know what actions you need to unbind since they’re done by name and not by input. There’s almost no case where you’d need UnbindAllActions except for debugging or some really esoteric case; or in a case where you actually do need it and have a means of restoring the original bindings if necessary.

1 Like

well im constantly changing whats being bound to lmb and at some point i want it to just be set to normal but i wont know what is currently bound to unbind it

When I bind action1 to the key F using the BindAction method, then bind aciton2 to the key F using the BindActionAtPriority method, it only calls the function corresponding with the BindAction method instead of the BindActionAtPriority method (regardless of the priority or order in which I bind them). Is there a reason for this?