function onTouched(hit)
debounce = false
local humanoid = hit.Parent:findFirstChild("Humanoid")
debounce = true
if (humanoid ~= nil) then
humanoid.Health = humanoid.Health - 10
wait(2)
debounce = false
end
end
script.Parent.Touched:connect(onTouched)
✓ ANSWER ACCEPTED
Did I do Debounce correctly?
1 answer
✓ Accepted answer
debounce is so you will only press a button once instead of it getting called a bunch of times.
debounce = false
function onTouched(hit)
if debounce == false then
local humanoid = hit.Parent:findFirstChild("Humanoid")
debounce = true
if (humanoid ~= nil) then
humanoid.Health = humanoid.Health - 10
wait(2)
end
end
debounce = false
end
script.Parent.Touched:connect(onTouched)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Yes, I understand that. I know what debounce is.