hi i want a button that only can be triggable every 3 seconds with clickdetector plz help:)
This can be solved with debounce!
debounce is a variable that is set to true or false at the start of a script, Example:
local debounce = false
If you want your button to be triggerable every 3 seconds, simply make an if statement at the begginging of the function, wait(3)
and change the value of debounce.
local debounce = false function ButtonPress() if debounce == false then debounce = true -- PUT OTHER STUFF HERE wait(3) debounce = false end end script.Parent.ClickDetector.MouseClick:connect(ButtonPress)
And thats it, you can also check debounce in the scripting glossary on the website!
You can use the debounce
method:
local cooldown = false script.Parent.ClickDetector.MouseClick:connect(function() if not cooldown then --Do your stuff here cooldown = true wait(3) cooldown = false end end)