So this is a pretty basic question, and I've looked at all the sources I could but couldn't really get a direct answer, so I'll ask here: how do I make a KeyDown()
/UserInputService()
that the players can't spam? For example
My Example
Let's say that you made a code that the player presses a certain key on their keyboard and an action happens, how would I make it so that way they can't spam the function? Something like this
function onKeyDown(input) local key = input.KeyCode if key == Enum.KeyCode.Z then --function end game:GetService('UserInputService').InputBegan:connect(onKeyDown)
So..
Can you guys help me based off my example? Thanks for looking at my question, have a good day.
Greek
local Ready = true function onKeyDown(input) local key = input.KeyCode if key == Enum.KeyCode.Z and Ready == true then Ready = false -- Put code here wait(1) Ready = true end game:GetService('UserInputService').InputBegan:connect(onKeyDown)