Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to put cooldown on a button?

Hey, How would I put a cooldown on a button, like, force the player to wait 10 seconds before the function of the button works again?

Thanks!

2 answers

This method in general is usually called a debounce.

The basic idea is that you keep track of some state of whether or not its enabled.

Whenever the event happens (like pressing the button) you mark it as disabled. After the time is up, you re-enable it.

That will end up looking something like this:

coolingDown = false

function event()
	if not coolingDown then
		-- Do whatever else
		-- Do whatever else
		--
		coolingDown = true
		wait(10)
		coolingDown = false
	end
end

-- calls / connections to `event`

At the very end of your script before the run command make a wait(10) command and insert any number you want in the parenthesis.

This discussion is preserved as it was. New answers, comments, and votes are closed.