I'd like to disable keyboard input for a few seconds for the key 'q' and then enable the player to use q again.
Could someone tell me how I would do this or if this is possible?
Thanks.
I'd like to disable keyboard input for a few seconds for the key 'q' and then enable the player to use q again.
Could someone tell me how I would do this or if this is possible?
Thanks.
Create a variable that checks if you can run the function or not.
--Must be in a LocalScript inside StarterGui or StarterPack.
ableToPressQ = true --The variable that checks if they are able to run the code.
mouse = game.Players.LocalPlayer:GetMouse() --Gets the mouse for the KeyDown event later.
mouse.KeyDown:connect(function(key) --Creates the function and event to fire when a key is pressed.
if ableToPressQ == true and (string.byte(key) == 113 or string.byte(key) == 81)) then --Checks if the variable lets you press Q or not, and checks if the actual key pressed was indeed the letter Q.
--Your Code
end --Ends the if statement.
end) --Ends the function.
If you want to change it so the player cannot press Q, then put ableToPressQ = false where you need it.
If I helped you, be sure to click the Accept Answer button below my character!
This discussion is preserved as it was. New answers, comments, and votes are closed.