So apparently when I have two players in a server and I want to make 1 of them on blue team and the other one on the red team, it does not work! However, it DOES work equally for 3, 4, 5, 6 and so on players.
I also printed the num value and it said 1, meaning that it will change one player to red in a two-player server.. However, it doesn't! If I replace num in the math.random function with 1, then it works perfectly. Any ideas what the problem is?
wait(5)
for _,v in ipairs(game.Players:GetPlayers()) do
v.TeamColor = BrickColor.new("Bright blue")
end
for _,v in pairs(game.Players:GetPlayers()) do
local num = math.floor(game.Players.NumPlayers/2) -- Estimate Down. On a two-player server it equals ONE.
local plrs = game.Players:GetPlayers()
if game.Players.NumPlayers > 1 then
wait(5)
local randteam = game.Players:GetChildren()[math.random(num,#plrs)] -- num = one.
randteam.TeamColor = BrickColor.new("Bright red")
end
end
Answer as soon as you can, thank you!
