Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have an issue with A Loop that doesn't stop working after an action is taken. How do I fix it?

Asked by 4 years ago
Edited 4 years ago

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 firePart = script.Parent 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?

0
I haven't read the whole thing, but have you tried using `break`? AltNature 169 — 4y
0
I tried that, but it didn't end the loop. Either am not implementing it correctly, or idk what am doing dragonspade21 15 — 4y

Answer this question