How do I get a specific team index?

I want to send the player to a specific team using if (Playspace.GetTeamCollection().AddToTeam[InAgent:agent, InTeam:team]):. But I don’t know how to choose a specific team to send the player to. Please help me!

Get first team:

var MaybeTeam1 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[0]}

get second team:

var MaybeTeam2 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[1]}

and so on.

I’m getting this issue:

EDIT:

Figured out that it has to happen within OnBegin and can’t be setup in the class.

Is there a way to declare a team variable for the class without assigning it a value?

Thank you! This helped me so much, appreciate it! - Foreignprince80 <3

1 Like

Just set it to “false”

Sorry for the nooby question, but how do I do that?

var MaybeTeam1 : ?team = false

1 Like

Last question sorry.
The variable now wants a value of type “?team” when I try set it, so “team” is incompatible. How exactly do I get around that?

Here is the documentation on option types (ie. ?type) that hopefully clarifies things here. Option.

In your case you would have:

var MaybeTeam1:?team = false # No team assigned
set MaybeTeam1 = option{ Team1 } # Now it is assigned to Team1

# Getting the value out
if (Team := MaybeTeam1?):
    DoSomethingWithTeam(Team)
1 Like

Thank you very much! That covers everything :slight_smile: