Hello, Yesterday I asked for help concerning a code i've been working on, and was able to get some, however more issues came up and am wondering if there is a way to fix the problem. I am trying to create a setting where if a player touches fire, they receive burn damage and fire/smoke effects till the touch the water. However, when the player touches fire, the loop goes on only once, and when touching the water, the effects of fire/smoke leaves but the burn damage stays and acts in a weird manner.
This is my fire Code
local Players = game.Players
firePart.Transparency = 1
local Lava = function(hitPart)
if hitPart.Parent:FindFirstChild("Humanoid") then
hitPart.Parent.Humanoid.Health = 100
if hitPart.Parent.Humanoid.Health > 0 then
local Parts = hitPart.Parent:GetChildren()
for i, Parts in pairs(Parts) do
if Parts:IsA("BasePart") then
Instance.new("Fire", Parts)
Instance.new("Smoke", Parts)
if Parts:FindFirstChild("Fire") then
repeat wait()
hitPart.Parent.Humanoid.Health = 100
hitPart.Parent.Humanoid.Health = hitPart.Parent.Humanoid.Health - 10
wait(0.5)
until Parts:FindFirstChild("Fire") == false
end
end
end
end
end
end
firePart.Touched:Connect(Lava)~~
And this is my water code
local waterPart = script.Parent
waterPart.Transparency = 1
local function PutOutFire(part)
if part.Parent.Humanoid then
local human = part.Parent:GetChildren()
for i, human in pairs(human) do
if human:FindFirstChild("Smoke") then
human:FindFirstChild("Smoke"):Destroy()
end
if human:FindFirstChild("Fire") then
human:FindFirstChild("Fire"):Destroy()
end
end
end
end
waterPart.Touched:connect(PutOutFire)
what will I need to do to fix it?

2 comments
I haven't read the whole thing, but have you tried using
break?I tried that, but it didn't end the loop. Either am not implementing it correctly, or idk what am doing