I have absolutely no idea what the debounce property does, if it even is a property, or how to use it.
I've looked in almost every page, blog, and even memorized a few. I still don't know how to use it at all. I know it prevents certain functions from repeating an excessive amount of times, but I just can't grasp anything else about it.
Debounce is actually a variable. Of course it's a boolean value and the way it works is a script checks if it's true and if it is, the function will end using return
. It's really useful for the Touched
event.
Example:
debounce = false --create the debounce, it can be named anything. function touch() if debounce == true then return end --If the debounce is true, the function will end using return. debounce = true --The debounce is now true. print("Touched!") wait(5) --So the code cannot be repeated for 5 seconds. debounce = false --The debounce is now false and the code can be repeated again. end workspace.Part.Touched:connect(touch)
~coo1o