Upon clicking the tool becomes activated, allowing you to press keys to do stuff. The problem is that when you unequip the tool it's still activated I guess, so the stuff still happens when you press the corresponding key.
function onActivated() uis.InputBegan:connect(function(input,process) if not process and input.KeyCode == Enum.KeyCode.V --Stuff happens here end end) end script.Parent.Activated:connect(onActivated)
local UserInputService = game:GetService("UserInputService") local activated = false local tool = script.Parent UserInputService.InputBegan:Connect(function(inp, gpe) -- switch to :Connect, :connect is deprecated if gpe and not active then return end if inp.KeyCode == Enum.KeyCode.V and activated then -- code end end) tool.Activated:Connect(function() active = true -- activate on activation end) tool.Unequipped:Connect(function(mouse) active = false -- deactivate end)