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

3 comments
try adding a debounce, works for me. like "if key == Enum.KeyCode.Z and debounce == false then debounce = true end"
Intresting, I'll try it out.
http://wiki.roblox.com/index.php?title=Debounce