Lets say I want to check for when a player presses a key with a specific tool equipped. I'd use mouse.KeyDown() in a local script in the tool. However, if I were un-equip the tool. then it would still check to see if the key is pressed. I know I could make a variable that is true when the tool is equipped and make it false when it isn't and put that within an if statement in KeyDown(), but is there a more efficient way?
Stop calling an event?
2 answers
Wow, you're having the same problem I was having
when I wanted to do this.
But there's an easy solution, context action service.
It lets you press a button to activate a function but you can bind an unbind it whenever you want. So, if you don't want someone to do the function when their tool is unequipped just unbind the function when the tool is unequipped. To learn to use it just go to the tutorial above.
I'm not entirely sure about this, but I looked on the wiki, and it said you can try RBXScriptConnection:disconnect to stop events. You can look harder than I did, but ever since the overhaul, it's been really difficult to find what you need. If that doesn't work, then I'm afraid you'll have to use the variable.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thanks, but what if I also wanted to check if a player dies when his character is added to the game?
Do you mean in the script above or do you just want to know to know.