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

how do you use dbounce?

Asked by 11 years ago

ok

pls help

thx vry much

zeyd

4 answers

Log in to vote
1
Answered by 11 years ago

hiiii

Ad
Log in to vote
1
Answered by
reaper5 10
11 years ago
1local script_is_running = false
2script.Parent.Touched:connect(function (newbie)
3script_is_running = true
4 
5-- SCRIPT STUFF HERE
6 
7wait(5)
8script_is_running = false
9end)

Will prevent it from being fired every 5 seconds.

if you found this useful please choose it as the correct answer

Log in to vote
0
Answered by
Hybric 271 Moderation Voter
11 years ago

debounce is mainly in tools (Supposedly) Also mainly in hats. I believe it is in a Touched function.

0
Debounce is a term that is often associated with the act of adding a cool-down time to a function so it doesn't get called rapidly. This can be especially helpful when used in conjunction with the Touched event of parts. Oftentimes, this is accomplished by setting a variable to true at the beginning of a function, and setting it to false again at the end. Then, at the very beginning of the functio Hybric 271 — 11y
0
n, and setting it to false again at the end. Then, at the very beginning of the function, if the variable is already true, then you use the 'return' keyword, effectively ending the function. Hybric 271 — 11y
Log in to vote
0
Answered by
Kozero 120
11 years ago

Debounce is used so a function's event doesn't run too many times For example:

01Debounce=true
02Part=Workspace.Part
03function ChangeColor()
04if Debounce==true then
05Deb=false
06Part.BrickColor=BrickColor.new"Bright red"
07wait(2)
08Part.BrickColor=BrickColor.new"Bright blue"
09Debounce=true
10end
11script.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.

Answer this question