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

De lagging a for loop with an if statement?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

So I have a for loop that checks to see if the variable 'calloff' is true, if it's true then it stops the for loop, how would I make it so it doesn't instance abuse?

local finished = false
local calloff = false

coroutine.wrap(function()
        for racewait = 175, 0, -1 do
        wait(1)
        if calloff == false then
            game.Workspace.StartingLine.Timer.SurfaceGui.Time.Text = "Race time: "..racewait
                for _, Player in pairs(game.Players:GetChildren()) do
                    if Player:IsA("Player") then
                        Player.PlayerGui.MainGui.TimeFrame.Timer.Text = "Race time: "..racewait
                    end
                end
            else
        end
    end
finished = true
end)() 

game.Workspace.Positions.Last.Changed:connect(function()
    if game.Workspace.Positions.Last == true then
        calloff = true
        wait(1)
        calloff = false
    else
        calloff = false
    end
end)

0
I'm not sure if this is what you mean, but you should break the loop if 'calloff' is true. saenae 318 — 9y

Answer this question