getAssignedTeam(self) only gives me 0

init()
{
    level endon("game_ended");
    level thread PrintAssignedTeam();
}

PrintAssignedTeam()
{
    for (;;)
    {
        wait 1;

		team = getAssignedTeam(self);

        iprintln("You are team: " + team);
		
    }
}

On this script i only get the number 0. Wich means i am in not a team. But i choosed a team and it still said 0. What did i do wrong? And if it isnt working what can i do to find out wich team a player is?

This will get it to say axis or allies

init()
{
	level thread onPlayerConnect();
}
onPlayerConnect()
{
	for( ;; )
	{
	level waittill( "connecting", player );
	player thread onSpawnPlayer();
		
	}
}
	
onSpawnPlayer()
{
	self endon ( "disconnect" );
	while( 1 )
	{
	self waittill( "spawned_player" );
	wait 1;

	team = self.team;

    iprintln("You are team: "+team);
	}
}

If you actually want the team name then:

init()
{
	level thread onPlayerConnect();
}
onPlayerConnect()
{
	for( ;; )
	{
	level waittill( "connecting", player );
	player thread onSpawnPlayer();
		
	}
}
	
onSpawnPlayer()
{
	self endon ( "disconnect" );
	while( 1 )
	{
	self waittill( "spawned_player" );
	wait 1;

	if (self.team == "allies")
	{
	team = getDvar( "g_TeamName_Allies" );
    iprintln("You are team: "+team);
	}
	else
	{
	team = getDvar( "g_TeamName_Axis" );
    iprintln("You are team: "+team);
	}
}
}