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

[Please Help] How to stop a for loop based on bool value?

Asked by 3 years ago
Edited 3 years ago

So I have this round system, it works fine, but I want to make it stop based on a bool value changing. To further explain, say I have 2 number values which represent the points of each team. When the value hits the max number limit, then a bool value is set to true. This bool value is supposed to end the loop when set to true. Code below:

function teamDeathMatch()
    print("Team Deathmatch Chosen")

    for i = prepare, 0,-1 do
        inround.Value = true
        status.Value = "Game Starting in "..i
        wait(1)
    end

    for i = tdm, 0,-1 do
        status.Value = i
        wait(1)
        if inround.Value == false then
            inround.Value = true
        end
        if b.Value == true then -- This is what I tried using but it didnt work. B is a shortcut for a bool value in serverstorage.
            break
        end
    end

    wait(10)
    spawn(casualTimer)
end

As stated in the code sample, it does not work. So how can I make this for loop end to go on in the code? Please help, this is a server script in serverscriptservice.

0
this looks like it should work, can you post the script that changes the boolvalue? OfficerBrah 494 — 3y

Answer this question