I made a button that has a cooldown, but everytime it is clicked during cooldown, it just starts the whole cooldown over again. Any ways to combat this?
function OnClicked() wait(1) script.Parent.BrickColor = BrickColor.new("Really red") script.Parent.Running.Value = false wait(60)--starts wait over again. script.Parent.BrickColor = BrickColor.new("Lime green") script.Parent.Running.Value = true end script.Parent.ClickDetector.MouseClick:connect(OnClicked)--everytime the button is clicked it starts wait over again.
Need to add a debounce like this:
debounce = false function OnClicked() if debounce == false then debounce = true wait(1) script.Parent.BrickColor = BrickColor.new("Really red") script.Parent.Running.Value = false wait(60)--starts wait over again. script.Parent.BrickColor = BrickColor.new("Lime green") script.Parent.Running.Value = true debounce = false end end script.Parent.ClickDetector.MouseClick:connect(OnClicked)--everytime the button is clicked it starts wait over again.