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

How to put this function in a loop while keeping the others going?

Asked by
wjs3456 90
10 years ago

Ok I have this function here that checks the amount of players on a team:

function getTeam(team)
    local players = game.Players:GetPlayers();
    local teamPlayers = {};
    for _, player in pairs(players) do
        if player.TeamColor == team.TeamColor then
            table.insert(teamPlayers, player);
        end
    end
    return teamPlayers;
end

And then I used it to start another function.

function waitforwinner()
if #getTeam(game.Teams.Survivors) == 0 then
        m = Instance.new("Message",Workspace)
            m.Text = "The final survivor was infected. Once you respawn the round will begin!"
        wait(3)
    m:Destroy()         
        for i,v in pairs(game.Players:GetPlayers()) do
            if v.TeamColor == BrickColor.new("Bright orange") then
            v.StarterGear.Revolver:remove()
        end
            v.Character.Humanoid.Health = 0
            wait(1)
            v.TeamColor = BrickColor.new("Bright blue")
            wait(5)         
        begin("The round has begun.",3)
        GiveGun()
        FirstInfected("A player has been randomly infected!",3)
        waitforwinner()
        waitForWinner()
        end
        end
end

The problem is that the getTeam function only checks once. So is there a way to make it so that function keeps checking so the second function will know when to work?

0
Do not duplicate questions. BlueTaslem 18071 — 10y
0
Can I get help with it. I know I shouldn't but how am I supposed to use this answer wjs3456 90 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

I dont believe you can run multiple functions at once on 1 script. This is because scripts read it how you would read it. Up and down. It cant split vision.

Ad

Answer this question