I'm trying to make a slow kill script to slowly kill a person when they are on the brick, but it stops damaging the person when they step off of it. Here's the code I have, it works but it doesn't stop when they step off the brick:
function onTouched(hit)
local h = hit.Parent:findFirstChild("Humanoid")
repeat
h.Health = h.Health - 0.2
wait(2)
until h.Health == 0
end
script.Parent.Touched:connect(onTouched)

3 comments
do not use while wait() do
@MCAndRobloxUnited I don't think you understand how this works. They would have the same functionality, and I can gaurentee you are incorrect.
Thanks