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 10 years ago

ok

pls help

thx vry much

zeyd

4 answers

Log in to vote
1
Answered by 10 years ago

hiiii

Ad
Log in to vote
1
Answered by
reaper5 10
10 years ago
local script_is_running = false
script.Parent.Touched:connect(function (newbie)
script_is_running = true

-- SCRIPT STUFF HERE

wait(5)
script_is_running = false
end)

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
10 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 — 10y
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 — 10y
Log in to vote
0
Answered by
Kozero 120
10 years ago

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

Debounce=true
Part=Workspace.Part
function ChangeColor()
if Debounce==true then
Deb=false
Part.BrickColor=BrickColor.new"Bright red"
wait(2)
Part.BrickColor=BrickColor.new"Bright blue"
Debounce=true
end
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.

Answer this question