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
|