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

How to have 2 random teams?

Asked by 10 years ago
players = game.Players:GetChildren()

for i,v in pairs(players) do
    print(v.Name .. " is on red team")
        v.TeamColor = BrickColor.new("Bright red")
end
for i,v in pairs(players) do
    print(v.Name .. " is on blue team")
        v.TeamColor = BrickColor.new("Bright blue")
end

How can I get this to just pick 2 random teams

1 answer

Log in to vote
1
Answered by
samfun123 235 Moderation Voter
10 years ago

To make players go on to two random teams you would need to do :

players = game.Players:GetChildren()

teams = {"Bright red","Bright blue"} -- Defines the team colors, you can add more

for i,v in pairs(players) do -- Loops through the players
            v.TeamColor = BrickColor.new(teams[math.random(1,#teams)]) -- Picks one of the brick colors out of the teams table
end

If you have any questions, concerns or just need some help with this PM me on ROBLOX!

0
Thanks ;) NinjoOnline 1146 — 10y
0
ERROR< 2 people spawned on the same team, so 2 v 0 how can I fix? NinjoOnline 1146 — 10y
0
I PM'ed you the fixed code! samfun123 235 — 10y
Ad

Answer this question