Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you make a delay between doing damage?

Asked by 4 years ago

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

Thanks.

3 answers

Log in to vote
1
Answered by 4 years ago

Simply add something called a debounce, here's an tutorial on it: https://www.youtube.com/watch?v=HoZkuvd6RPA

Ad
Log in to vote
0
Answered by
ghxstlvty 133
4 years ago

Just use a wait statement...

wait(2)

How many seconds you want it to wait in between.

Log in to vote
0
Answered by 4 years ago

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

Answer this question