How do you switch entire teams with verse?

How would you go about setting players from team one to team two and team two to team one using verse?

You can use these functions when placed inside a creative device

You can then do if(AgentsTeam:=GetTeam[Agent]): which returns the “team” type and also eg if(Team2:=GetTeam[2]): which returns the “team” type of team 2
Afterwards you can either use SetTeam(Agent,TeamReferenceHere) or SetTeam(Agent,2) to change their teams

    GetTeam(Integer:int)<decides><transacts>:team=
        TeamColl:=GetPlayspace().GetTeamCollection()
        TheTeam:=TeamColl.GetTeams()[Integer+1]
        return TheTeam
    GetTeam(Agent:agent)<decides><transacts>:team=
        TeamColl:=GetPlayspace().GetTeamCollection()
        TheTeam:=TeamColl.GetTeam[Agent]
        return TheTeam
    SetTeam(Agent:agent,Team:team):void=
        TeamColl:=GetPlayspace().GetTeamCollection()
        if. TeamColl.AddToTeam[Agent,Team] else. Print("FAILED TO ADD TO TEAM")
    SetTeam(Agent:agent,Integer:int):void=
        TeamColl:=GetPlayspace().GetTeamCollection()
        if. TeamColl.AddToTeam[Agent,TeamColl.GetTeams()[Integer]] else. Print("FAILED TO ADD TO TEAM")

Thanks for the help!

1 Like

How would you go about switching the entire team at one time? I can get one player to switch teams with this code, but i’m having trouble getting the whole team to switch teams

for(Player:GetPlayspace().GetPlayers()):
    SetTeam(Player,1)