Can someone explain what a debounce is and how does it work?
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:
1 | debounce = false --true or false, doesn't matter |
2 |
3 | script.Parent.Touched:connect( function (player) --The brick gets touched and calls the player |
4 | if debounce = = false then --Checks to see if it is false |
5 | debounce = true --Now no one can touch the brick until debounce = false |
6 | --Code to give player Money |
7 | wait( 10 ) debounce = false --Waits 10 seconds before the brick can give money again. |
8 | end |
9 | end ) |
I hope that I've answered your question :D.