I have a local script that uses user input service to do stuff when u press certain keys, but I only want that stuff to happen when a certain tool is equipped.
What I tried to do was adding a local script inside the tool, and when the tool is equipped set the UIS script’s disabled to false, and when the tool is unequipped set it to true, but that didn’t work for some reason, how could I do it?
(I tried putting the UIS stuff inside the tool’s local script, and using connections, to connect when you equip and disconnect when u unequip, but it did not work)
.Disabled is not the right way to solve this. My suggestion is to handle this in the same script as the UIS script, using a local variable and Equipped/Unequipped:Connect as a switch, while checking at every other function if Equipped = true, and return end if it is false.
I tried this, I made a variable and set it to true when equipped and false when unequipped, and then in the UIS.InputBegan connected function I checked if that variable was false, if it was it would return, but when I equipped the tool I still couldn’t press the keys
Strange. Did you put the local variable outside the functions and did you not accidentally redefine the variable within the function? This is within my knowledge the only way to detect if you’re actually using the tool. Does your tool also have a handle? If it doesn’t, .Equipped cannot be detected.
fazer o que mano eu to no celular ta dificil pc quebrou ai não tenho os comandos decorados, também não sou tão avançado sabe to aprendendo pra eu conseguir fazer jogo daora ai eu fico no developer hub e não entendi muito bem o que você queria fazer.