I'm trying to make it so when the match starts, it devides all the players in the game into 2 teams. This is my code, it doesn't error, but it doesn't work. By the way, I trigger startMatch() in the rest of my script. Can anybody help?
function startMatch()
local numplayers = script.PlayerCount.Value
if numplayers >= 2 then
local blue = math.ceil(numplayers/2)
local green = math.floor(numplayers/2)
print(blue)
print(green)
for i,v in pairs(game.Lighting.Weapons:GetChildren()) do
v:Clone()
v.Parent = game.StarterPack
print(v.Name)
end
child = game.Players:GetChildren()
for i = 1, blue do
if child.TeamColor ~= BrickColor.Green() then
child.TeamColor = BrickColor.Blue()
end
end
for i = 1, green do
if child.TeamColor ~= BrickColor.Blue() then
child.TeamColor = BrickColor.Green()
end
end
end
end
