# How to get the team index of the agent?

**URL:** <https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [October 23, 2023, 7:04am UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500 "2023-10-23T07:04:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Messiah4213](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/messiah4213/32/764721_2.png) [@Messiah4213](https://forums.unrealengine.com/u/Messiah4213)\
**Post date:** [October 23, 2023, 7:04am UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/1 "2023-10-23T07:04:53Z")

</div>

Hello!  
I know this is a basic question but I still do not understand how to do this.

What I want to do is if the agent push the button change the Maximum health of the agent’s team.  
Thank you in advance!

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 23, 2023, 11:18am UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/3 "2023-10-23T11:18:28Z")

</div>

Hey, you can use `fort_team_collection` to do this, something like

```auto
TeamCollection := GetPlayspace().GetTeamCollection()
if(
    PlayerTeam := TeamCollection.GetTeam[Player],
    PlayerAllies := TeamCollection.GetAgents[PlayerTeam]
):
    for(Ally : PlayerAllies):
        # DO STUFF

```

Be careful, the `fort_team_collection.GetAgents[]` method returns agents (creatures/guards…) not players, so you might need to cast them to players if you only want to change the players health.

---

<div class="post-metadata">

**Author:** ![Messiah4213](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/messiah4213/32/764721_2.png) [@Messiah4213](https://forums.unrealengine.com/u/Messiah4213)\
**Post date:** [October 23, 2023, 1:13pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/4 "2023-10-23T13:13:17Z")

</div>

Thank you for your reply LAMA-san!  
Is there any way to get the index of the team?  
I can get the type :team but I dont know how to get the team1 or team2.  
Thank you again

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 23, 2023, 1:26pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/5 "2023-10-23T13:26:06Z")

</div>

Hey, so I don’t know an easy way to do it, but you could do try that :

```auto
TeamCollection := GetPlayspace().GetTeamCollection()
if(
    PlayerTeam := TeamCollection.GetTeam[Player],
    VerseTeamIndex := TeamCollection.GetTeams().Find[PlayerTeam],
    CreativeTeamIndex := VerseTeamIndex + 1 # Array indexes start from 0, creative team indexes start from 1
):
    # DO STUFF

```

---

<div class="post-metadata">

**Author:** ![Messiah4213](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/messiah4213/32/764721_2.png) [@Messiah4213](https://forums.unrealengine.com/u/Messiah4213)\
**Post date:** [October 23, 2023, 2:13pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/6 "2023-10-23T14:13:22Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/6/0/2600fc3e8091574ca06a4eb2fabfdbe5fad669ee.png)

CreativeTeamIndex is type int right?  
Can I do like this image?  
Im so beginner…

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 23, 2023, 2:16pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/7 "2023-10-23T14:16:21Z")

</div>

Your indent is wrong 🥲

---

<div class="post-metadata">

**Author:** ![Messiah4213](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/messiah4213/32/764721_2.png) [@Messiah4213](https://forums.unrealengine.com/u/Messiah4213)\
**Post date:** [October 23, 2023, 2:18pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/8 "2023-10-23T14:18:18Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/5/4450a3ee67be370f9fdc23fa10e5ff45d1334fae.png)  
Oh Sorry but when I fix like this its become more troubles…

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 23, 2023, 2:24pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/9 "2023-10-23T14:24:25Z")

</div>

Yes I know, it’s pretty easy to solve but I’ll let you find how, good luck 🙂

---

<div class="post-metadata">

**Author:** ![Messiah4213](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/messiah4213/32/764721_2.png) [@Messiah4213](https://forums.unrealengine.com/u/Messiah4213)\
**Post date:** [October 23, 2023, 3:29pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/10 "2023-10-23T15:29:13Z")

</div>

I could fix by my self thank you very much!! 😄

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 22, 2023, 3:29pm UTC](https://forums.unrealengine.com/t/how-to-get-the-team-index-of-the-agent/1341500/11 "2023-11-22T15:29:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
