# Getting the team of a Player

**URL:** <https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite\
**Created:** [March 18, 2023, 4:04pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700 "2023-03-18T16:04:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [March 18, 2023, 4:04pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/1 "2023-03-18T16:04:29Z")

</div>

I am trying to get the team of a player as an `int` value using verse code. I am not sure but I think I have to use `GetPlaySpace` for this. But I can only seem to get something of type `team`. I do not know what this type `team` is and I do not think there is any documentation on this.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/4/9243cebb8a7834ce56d78d84332d18af20c13faf.png)

---

<div class="post-metadata">

**Author:** ![Tom.Noonan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tom.Noonan](https://forums.unrealengine.com/u/Tom.Noonan)\
**Post date:** [March 22, 2023, 7:55pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/2 "2023-03-22T19:55:00Z")

</div>

The team should have a stable index in the GetPlayspace().GetTeamCollection().GetTeams() array if you want a representative team number.

```auto
    TeamCollection := GetPlayspace().GetTeamCollection()

    if (AgentsTeam := TeamCollection.GetTeam[Agent]):

        TeamArray := TeamCollection.GetTeams()

        for (TeamNumber->Team : TeamArray):
            
            if (AgentsTeam = Team):
                # If you get here the team's number will be TeamNumber

```

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [March 23, 2023, 5:07pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/4 "2023-03-23T17:07:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tom.Noonan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tom.Noonan](https://forums.unrealengine.com/u/Tom.Noonan)\
**Post date:** [March 23, 2023, 5:21pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/5 "2023-03-23T17:21:36Z")

</div>

If you have the number of teams set in your IslandSettings the TeamArray should be the same length as that. That being said we did encounter an issue internally where creative team indices were not matching the team indices in verse which should be fixed in an upcoming release.

---

<div class="post-metadata">

**Author:** ![FinestCreative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/finestcreative/32/1034971_2.png) [@FinestCreative](https://forums.unrealengine.com/u/FinestCreative)\
**Post date:** [March 23, 2023, 6:07pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/7 "2023-03-23T18:07:08Z")

</div>

Actually, the array does not contain just 1 team like I said before, but it indeed it is equal to the number of teams in the island settings like you said. But yeah, for whatever reason I am always the 1st team (index 0) in the array, no matter what my team is

---

<div class="post-metadata">

**Author:** ![JordanyJaxxen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JordanyJaxxen](https://forums.unrealengine.com/u/JordanyJaxxen)\
**Post date:** [February 7, 2024, 3:08pm UTC](https://forums.unrealengine.com/t/getting-the-team-of-a-player/793700/8 "2024-02-07T15:08:21Z")

</div>

Hello, I have a same type of problem. I want that, if the Playercounter1 is true, then all Players that are not in Team1, to automatically switch to Team 2. And if he Playercounter2 is true, then all Players that are not in Team2, to automatically switch to Team 1. For a Box fights. May you guys help me with the code in Verse. Would help me a lot. Thanks \<3
