ok
pls help
thx vry much
zeyd
ok
pls help
thx vry much
zeyd
hiiii
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
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:
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
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
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.