Hi all! I am building a custom inventory system, and in order to assign tools to a toolbar slot, I am calling var = UserInputService.InputBegan:Wait()
. This yields the current thread and assigns the user’s next input to a variable. Users press one of the number keys, 1 through 6, to assign it to a hotkey slot.
If a user attempts to assign a tool to a slot which is already taken, my internal notification system tells them that they are unable to do that and cancels the assignment. This behaviour works as expected.
However, if there is already a tool in that slot, pressing that number key equips the tool as well. This is because I have bound the number keys using ContextActionService to allow users to use/put away the tool.
I have looked through the documentation, but cannot find much mention of the :Wait()
method being used with InputBegan, and thus no mention of this issue where waiting for an input does not stop that input’s regular functions from firing.
How can I prevent the regular functions from firing while I have the InputBegan:Wait()
method triggered?
The flashlight (or whatever tool is there at the time) equipping is the unwanted behaviour. The #2 key is bound to taking out/putting away the flashlight, but I would like my script to ignore this bind while the :Wait()
method is getting an input.
Your help would be appreciated!