Team Number

Hello, i was trying to get the Team Number from an agent, but its not working right, does anyone know how to get the team number right?

GetTeam(Agent:agent):int={
if(TeamNumber := TeamMap[Agent]):
return TeamNumber
else:
return -1
}
var TeamMap:[agent]int = map{}

OnTheBossDamage(Agent : agent): void=
    if (GetTeam(Agent) = 2):
        Print("No")
    else BossBar.TakeDamage(20.0)

Check out the part on Splitting Teams Equally.

team_multiplayer_balance := class(creative_device):
     # Holds the teams found with GetTeams() 
     var Teams : []team = array{}
OnBegin<override>()<suspends>:void=
     Print("Verse Device Started!")
     set Teams = Self.GetPlayspace().GetTeamCollection().GetTeams()
     AllPlayers := GetPlayspace().GetPlayers()