1 | local script_is_running = false |
2 | script.Parent.Touched:connect( function (newbie) |
3 | script_is_running = true |
4 |
5 | -- SCRIPT STUFF HERE |
6 |
7 | wait( 5 ) |
8 | script_is_running = false |
9 | end ) |
Will prevent it from being fired every 5 seconds.
if you found this useful please choose it as the correct answer
debounce is mainly in tools (Supposedly) Also mainly in hats. I believe it is in a Touched function.
Debounce is used so a function's event doesn't run too many times For example:
01 | Debounce = true |
02 | Part = Workspace.Part |
03 | function ChangeColor() |
04 | if Debounce = = true then |
05 | Deb = false |
06 | Part.BrickColor = BrickColor.new "Bright red" |
07 | wait( 2 ) |
08 | Part.BrickColor = BrickColor.new "Bright blue" |
09 | Debounce = true |
10 | end |
11 | script.Parent.Touched:connect(ChangeColor) |
Here If the Debounce is true then the function will start when the event is connected to the function and it will not fire if the Debounce is false. Instead of using Debounce you can use a wait() to stop functions from clashing.