Getting the team of a Player

Thanks, but it is not what I am looking for. This works fine if you have players in team 1, 2, 3 etc. But if you have just 1 player in the map that is on team 2, after if (AgentsTeam = Team): TeamNumber will be 0, because TeamArray only contains a single team, team 2. What I expect is TeamNumber to be 1 for team 2 but this code does not work like that.