As the title sais, I'm asking this because I've seen many people post a script like this, and some my answers have had Debounce defined like that. Thanks for the Help.
Debounce is a design pattern. The name debounce
doesn't mean anything special
to Lua, and really, you should be using a better name than that.
I prefer the name enabled
. Before proceeding, you always check that you are
enabled
. You can choose to disable yourself by setting enabled
to false
.
Code looks like this:
local enabled = true -- start on function doThing() if enabled then -- I'm allowed to work enabled = false -- but I'm temporarily disabled while I work -- (do stuff) wait(5) enabled = true -- I'm available to work again end end
Debounce is a variable, meaning that, it can be named whatever you want. I guess a person that at least understands a bit a variables would know this.