So i created this script that at the start of the round it creates 2 teams called blue and red. However when the round starts people wont get auto assigned to the teams and yes the autoassigned propertie is turned ON!. So does anyone know why this is happening?

local Teams = {game.Teams.Red,game.Teams.Blue}
for i,v in pairs(game.Players:GetPlayers()) do
local RandomTeam = Teams[math.random(1,#Teams)]
v.Team = RandomTeam
end

local Teams = {game.Teams.Red,game.Teams.Blue} -- this table contains both teams instances Which is game.Teams.Red,game.Teams.Blue
for i,v in pairs(game.Players:GetPlayers()) do -- looping through all of the players by using for i,v in pairs loop in this case i is the index and v is the value which is our player.
local RandomTeam = Teams[math.random(1,#Teams)] -- selecting a Random Team from the Teams table.
v.Team = RandomTeam -- v which is the player we will set his Team to the random team.
end

Thanks!, 1 last thing. Due to were using math.random will the teams stay even? so for example when theres 10 people that 5 people are red and 5 people are blue and not 7 people red and 3 people blue for example?

local t = false
local Teams = {game.Teams.Red,game.Teams.Blue}
for i,v in pairs(game.Players:GetPlayers()) do
if t == false then
v.Team = Teams[1]
t = true
else
v.Team = Teams[2]
t = false
end

local t = false -- we create a boolean variable called t
local Teams = {game.Teams.Red,game.Teams.Blue} -- Teams Table
for i,v in pairs(game.Players:GetPlayers()) do -- Looping through all of the players by using for i,v in pairs loop so i is the index and v is the value which is our player.
if t == false then -- Checking if the t is equals to false
v.Team = Teams[1] -- if so the Player's Team will be the first value in the table which is game.Teams.Red
t = true -- we set t to true
else
v.Team = Teams[2] -- we set the player Team to the 2nd value in the table which is game.Teams.Blue
t = false -- we set t to false.
end

local t = 1
local Teams = {game.Teams.Red,game.Teams.Blue,game.Teams.Green,game.Teams.Yellow}
for i,v in pairs(game.Players:GetPlayers()) do
if t == 1 then
v.Team = Teams[1]
t = 2
elseif t == 2 then
v.Team = Teams[2]
t = 3
elseif t == 3 then
v.Team = Teams[3]
t = 4
elseif t == 4 then
v.Team = Teams[4]
t = 1
end

local Teams = {game.Teams.Red,game.Teams.Blue,game.Teams.Green,game.Teams.Yellow}
for i,v in pairs(game.Players:GetPlayers()) do
TeamSelector(v)
end
local t = 1
function TeamSelector(v)
v.Team = Teams[t]
t += 1
if t == 4 then
t = 1
end
end

or

local t = 1
local Teams = {game.Teams.Red,game.Teams.Blue,game.Teams.Green,game.Teams.Yellow}
for i,v in pairs(game.Players:GetPlayers()) do
v.Team = Teams[t]
t += 1
if t == 4 then
t = 1
end
end