Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with Team Deviding?

Asked by 10 years ago

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

Answer this question