I wanted to make a brick so when you are on it, it slowly damages you as long as you are on it. For example, you're head is in a water brick and you are supposed to drown, right? So you slowly lose 5 health until you die as long as your head is underwater. How can I do this? This is my script and it seems to not work.
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then for i = 1, 2000 do wait(1) h.Health = h.Health - 5 end end end script.Parent.Touched:connect(onTouched)
local debounce = false script.Parent.Touched:connect(function (hit) if not debounce then debounce = true guy = hit.Parent:FindFirstChild("Humanoid") if guy ~= nil then --[[Next line is optional, it just makes the person unable to move. guy.Torso.Anchored = true]]-- guy.Health = guy.Health - 0.003 wait(0.01) debounce = true end end
I believe this would work hopefully