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

Why do players sort only in 2 teams when there are 4?

Asked by
imKlevi 94
3 years ago
game.Players.PlayerAdded:Connect(function(player)

    local Teams = {
        game.Teams.Red,
        game.Teams.Blue,
        game.Teams.Yellow,
        game.Teams.Green,
    }

    for i,v in pairs(game.Players:GetPlayers()) do
        local prevPlayers, prevTeam

        for j,k in pairs(Teams) do
            if not prevPlayers then
                prevPlayers, prevTeam = #k:GetPlayers(),k 
            elseif prevPlayers <= #k:GetPlayers() then
                v.Team = prevTeam
            elseif prevPlayers > #k:GetPlayers() then
                v.Team = k
            end
        end
    end

end)

Players sort only in "Red" and "Green" teams instead of sorting in 4 teams. E.g if there are 4 players on team there will be only 2 on "Red" and 2 on "Green" instead of being 1 in each. Please help me.

1 answer

Log in to vote
1
Answered by 3 years ago

NO SCRIPT first go to the teams folder and create 4 teams change the name of the teams and enable autoassignment

Ad

Answer this question