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)
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)