Fixed. Thanks me!
anyway the reason it was looping was because I accidently put it in my loop elsewhere.
and it wasn't assigning a color because the first if statement said if the TeamColor == "White", which it didn't understand so it skipped EVERYTHING else. what I did to fix it was the if statement right below the for loop I said
if player.TeamColor == BrickColor.new("White") then
...
end
if you need an auto assign script, here you go. Works fine. any questions just shoot me a message!
--Assigns players to teams
function assignPlayers()
print("Assigning Teams")
local g=0;
local t=0;
for _,player in pairs(game.Players:GetChildren()) do
player.Neutral = false
if player.TeamColor == BrickColor.new("White") then
if t+1<=g then
player.TeamColor = BrickColor.new("Really black")
t = t+1
elseif g+1<=t then
player.TeamColor = BrickColor.new("Bright blue")
g = g+1
else
if math.random(2) == 1 then
player.TeamColor = BrickColor.new("Really black")
t = t+1
else
player.TeamColor = BrickColor.new("Bright blue")
g = g+1
end
end
end
player.Character.Humanoid:TakeDamage(1000)
end
end |