Im having a problem. I wanted to make a brick which while the player is on the brick, it damages him.
My script is:
script.Parent.Touched:connect(function(hit) while hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") do hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5 wait(1) end
end)
to me, the while do loop would only work if the player is still on the brick. But when I run it, its a soon as he steps on the brick, it continues to do the loop until he dies. I also tried this:
script.Parent.Touched:connect(function(hit) while hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") do while hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") do hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5 wait(1) end end
end)
and this:
script.Parent.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 5 wait(1) end
end)
But none of the above work. I really need help. Thank you Nachsor
