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

What is a debounce?

Asked by 10 years ago

Can someone explain what a debounce is and how does it work?

1 answer

Log in to vote
2
Answered by 10 years ago

It's basically a variable that prevents an event from going on and on. Here's an example:

Say you want to give a player Money:

debounce = false --true or false, doesn't matter

script.Parent.Touched:connect(function(player) --The brick gets touched and calls the player
    if debounce == false then --Checks to see if it is false
        debounce  = true --Now no one can touch the brick until debounce = false
        --Code to give player Money
        wait(10) debounce = false --Waits 10 seconds before the brick can give money again.
    end
end)

I hope that I've answered your question :D.

1
thanks NinjoOnline 1146 — 10y
1
No problem. If you need any more help, don't be afraid to ask me on ROBLOX: fahmisack123 fahmisack123 385 — 10y
Ad

Answer this question