I have a tool that makes a sound when a player clicks the left mouse button. Here's the script:
wait(0.01) repeat wait(0.01) until game.Players.LocalPlayer.Character function Down(mouse) if script.Parent.enabledValue.Value == true then script.Parent.Handle.Fire:Play() end end function Selected(mouse) mouse.Button1Down:connect(function() Down(mouse) end) end script.Parent.Equipped:connect(Selected)
Inside the tool is another script that sets the enabledValue (a bool value) to false and then true when r is pressed.
wait(0.01) repeat wait(0.01) until game.Players.LocalPlayer.Character function onKeyDown(key) key:lower() if script.Parent.enabledValue.Value == true then if key == "r" then script.Parent.enabledValue.Value = false wait(3) script.Parent.enabledValue.Value = true end end end function onSelected(mouse) mouse.KeyDown:connect(onKeyDown) end script.Parent.Equipped:connect(onSelected)
The script itself works fine, however when both the "r" key and the left mouse button are pressed at the same time, the script refuses to play forever until the tool is dropped and picked back up. Why is it doing this?