of     1   

imaginaryUberlyuber
#183805538Wednesday, February 17, 2016 4:24 AM GMT

I want to make a script that would change someone's team when they pressed a gui button (specifically a TextButton). Moreover, I only want to be able to be able to change teams when there less than a certain amount of people on that team. So can I do something like: for k,v in GetChildren(Team) do --Assuming that GetChildren returns a table [TAB]if (weird math stuff) do [TAB][TAB](What function do I use to switch teams?) [TAB]end end Thanks!
cofunction
#183805598Wednesday, February 17, 2016 4:25 AM GMT

local script: local player = game.Players.LocalPlayer button.MouseButton1Down:connect(function() player.TeamColor = BrickColor.new("Really red") --Team Colour end)
imaginaryUberlyuber
#183806175Wednesday, February 17, 2016 4:35 AM GMT

Thanks for the quick reply, but I still don't know how to return the amount of people on a team - I tried the function I talked about earlier, and it did not work. I made it so that it printed to the console, however it did not work. So does anyone know how to do this?
cofunction
#183806293Wednesday, February 17, 2016 4:38 AM GMT

local team = game.Teams.RedTeam --Example of a team in the service "teams" local RedTeam = {} --Empty Table wait(2) --Wait for players to spawn (remove later or somethin') for _, player in pairs (game.Players:GetChildren()) do --Loop through all the players if player.TeamColor == team.TeamColor then --Compare the players team color with "team". table.insert(RedTeam, player) --Inserts the player into the team end end --Test code to print all the players in read team: for i, v in pairs (RedTeam) do print(v) end

    of     1