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

How do you make a delay between doing damage?

I have a script that does damage but I don't know how to make a delay between doing damage.

Thanks.

3 answers

Just use a wait statement...

wait(2)

How many seconds you want it to wait in between.

just add a debounce, like one of the replies mentioned. debounces are for a block of code not to run in a certain amount of time. in your case you could do something like this:

debounce = false -- first we create a variable called debounce and set it to false

function damage()
	if not debounce then -- the code inside this block will only be executed if there's no cooldown (debounce is set to fall)
		debounce = true -- sets debounce to true
		-- do all the stuff you want here
		wait(1) -- cooldown
		debounce = false -- sets debounce to false
	end
end

feel free to clear any doubt about this

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