Tutorial page
This article is an easy tutorial.
All tutorials · Scripting tutorials
Scripting
This page is a tutorial about Scripting.
This tutorial goes over the term of debounce. Debounce is a bool variable that is used in scripting as a delay for events. For example, when something triggers a BasePart's touched function, it will fire multiple times in the same millisecond. To prevent this, an if statement is added checking if the debounce variable is true. If it is, it gets set to false and the code runs.
local debounce = true
part.Touched:Connect(function(hit)
if debounce == true then
debounce = false -- prevents script to run event again.
--Code runs here
debounce = true -- allows script to run event again.
end
end)
| Scripting (44) |
| ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| GUI (8) |
| ||||||||||
| Building (3) |
| ||||||||||
| Platform (8) |
| ||||||||||