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

How can I make random teams assign?

Asked by 6 years ago
Edited 6 years ago

I want to make players get randomly assigned to teams. I have one script for this, but its not really that good. Is there a better way to do this? Here is my script:

local assign = 1
for i,v in pairs(game.Players:GetChildren()) do
if assign = 1 then
assign = 2 
v.Team.BrickColor = BrickColor.new("Black")
else

assign = 1
v.Team.BrickColor = BrickColor.new("White")
end

1 answer

Log in to vote
1
Answered by 6 years ago

I hope this works for you, because it worked for me.

for key, value in pairs(game.Players:GetChildren()) do
    local TeamAssign = math.random(1, 3) --custom amount of teams
    if TeamAssign == 1 then
        value.TeamColor = BrickColor.new("Bright red")--your team here
        elseif TeamAssign == 2 then
           value.TeamColor = BrickColor.new("Bright blue") --your team here 
        elseif TeamAssign == 3 then
           value.TeamColor = BrickColor.new("Bright green")--your team here
        end
end

Here you go. Make sure that every team you put in this script exists in your game. Sincerely, DominusInfinitus

0
-1 for not having an explanation at all. User#24403 69 — 6y
0
BOI! I took his code and the only difference is the math.random function! RetroGalacticGamer 331 — 6y
0
you are being abusive RetroGalacticGamer 331 — 6y
0
Ill give you plus I dom:). CaptainD_veloper 290 — 6y
0
Thank you, and if you don't understand, just say it now so I can edit. RetroGalacticGamer 331 — 6y
Ad

Answer this question