This will randomize the player team.
I didn't know your teams' colors, so you will have to change the color to the color of that team.
for _, v in ipairs(game.Players:GetChildren()) do
print(v)
local randomTeam = math.random(1,4)
if randomTeam == 1 then
v.TeamColor = BrickColor.new("Earth green")
elseif randomTeam == 2 then
v.TeamColor = BrickColor.new("Cashmere")
elseif randomTeam == 3 then
v.TeamColor = BrickColor.new("Medium blue")
elseif randomTeam == 4 then
v.TeamColor = BrickColor.new("Lapis")
end
end
I recommend using PlayerAdded, if you want it to run when the player joins.
game.Players.PlayerAdded:Connect(function(player)
local randomTeam = math.random(1,4)
if randomTeam == 1 then
player.TeamColor = BrickColor.new("Earth green")
elseif randomTeam == 2 then
player.TeamColor = BrickColor.new("Cashmere")
elseif randomTeam == 3 then
player.TeamColor = BrickColor.new("Medium blue")
elseif randomTeam == 4 then
player.TeamColor = BrickColor.new("Lapis")
end
end)
1 comment
Player.Team = TeamObject