function hurt(hit)
local fire = hit.Parent.Torso:FindFirstChild("Fire")
local hp = hit.Parent:FindFirstChild("Humanoid")
while fire do
hp.Health = hp.Health -5
wait(1)
end
end
lava.Touched:connect(hurt)
I'm trying to make it so that if fire is on the player the player takes damage and if it isn't the while loop stops. However, I dunno how to stop it.
I've tried this as well
function hurt(hit)
local nofire = hit.Parent.Torso
local fire = hit.Parent.Torso:FindFirstChild("Fire")
local hp = hit.Parent:FindFirstChild("Humanoid")
if fire then
while true do
hp.Health = hp.Health -5
wait(1)
if nofire then
hp.Health = hp.Health +0
end
end
end
end
lava.Touched:connect(hurt)

1 comment
Change the if statement to if fire==nil then break end which will stop the while loop