# Verse: How the get the team of the eliminating player ?

**URL:** <https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 21, 2023, 3:39pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650 "2023-05-21T15:39:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_MMB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_MMB](https://forums.unrealengine.com/u/_MMB)\
**Post date:** [May 21, 2023, 3:39pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/1 "2023-05-21T15:39:30Z")

</div>

Hello, i tried really hard and watched tutorial for hours but am still a beginner and I don’t find a way to get the team of the eliminating player.

Can you please help me?

This is my code so far:

```auto
AllPlayers := GetPlayspace().GetPlayers()
            for (EliminationGamePlayer : AllPlayers):
                if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
                # Subscribe to character eliminated event.
                    FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)

OnPlayerEliminated(Result:elimination_result):void=
        Print("One player has been killed")
        EliminatingCharacter := Result.EliminatingCharacter
        if:
            FortCharacter := EliminatingCharacter?
            EliminatingAgent := FortCharacter.GetAgent[] 
        then:
            Print("We have the agent")
            >>>> Get the team index of the Eliminating Player.

```

Bonus: I am also looking to know the size of each team. (in my game there will only be only two teams) Thank youuu !

---

<div class="post-metadata">

**Author:** ![caioreix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/caioreix/32/703192_2.png) [@caioreix](https://forums.unrealengine.com/u/caioreix)\
**Post date:** [May 21, 2023, 8:43pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/2 "2023-05-21T20:43:30Z")

</div>

You can use the team collection to this:

`Team := GetPlayspace().GetTeamCollection().GetTeam[Agent]`

To get the agent just use your

`fort_character.GetAgent()`

To the size you can use

`TeamSize := GetPlayspace().GetTeamCollection().GetAgents[Team].Length`

E.g

```auto
TeamCollection := GetPlayspace().GetTeamCollection()
if(
    Agent := FortCharacter.GetAgent[]
    Team := TeamCollection.GetTeam[Agent]
    TeamAgents := TeamCollection.GetAgents[Team]
):
    TeamSize := TeamAgents.Length

```

---

<div class="post-metadata">

**Author:** ![\_MMB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_MMB](https://forums.unrealengine.com/u/_MMB)\
**Post date:** [May 21, 2023, 10:43pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/3 "2023-05-21T22:43:47Z")

</div>

Thank you for this.

For the teams i’d like to get a function that i call anytime and gives me the number of players in team 1 & 2.

Something like:

```auto
FORTNITE_GAME := class(creative_device):

        var NumberPlayersTeam1 : int = 0
        var NumberPlayersTeam2 : int = 0

OnBegin<override>()<suspends>:void=
        StartMap()
        UpdateNumberOfPlayersInTeam1and2() #it's a game with only 2 teams

UpdateNumberOfPlayersInTeam1and2() : void =
        #Something here that update the two vars with the number of players in each teams. 
        set NumberPlayersTeam1 := something
        set NumberPlayersTeam2 := something

```

I tried the following but it doesn’t work:

```auto
    UpdateNumberOfPlayersInTeam1and2()<decides>: void =
        var TheMaybeTeam1 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[0]}
        var TheMaybeTeam2 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[1]}
        # Getting the value out
        if(Team1 := TheMaybeTeam1?):
            set NumberPlayerTeam1 = GetPlayspace().GetTeamCollection().GetAgents[Team1].Length
            Print("The number of players in Team 1 is: {NumberPlayerTeam1}")
        if(Team2 := TheMaybeTeam2?):
            set NumberPlayerTeam2 = GetPlayspace().GetTeamCollection().GetAgents[Team2].Length
            Print("The number of players in Team 2 is: {NumberPlayerTeam2}")

```

---

<div class="post-metadata">

**Author:** ![caioreix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/caioreix/32/703192_2.png) [@caioreix](https://forums.unrealengine.com/u/caioreix)\
**Post date:** [May 22, 2023, 5:25am UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/4 "2023-05-22T05:25:48Z")

</div>

You can do like this:

```auto
var NumberPlayersTeam1 : int = 0
var NumberPlayersTeam2 : int = 0

OnBegin<override>()<suspends>:void=
    UpdateNumberOfPlayers()

UpdateNumberOfPlayers(): void=
    TeamCollection := GetPlayspace().GetTeamCollection()

    if (
        Team1 := TeamCollection.GetTeams()[0]
        set NumberPlayersTeam1 = TeamCollection.GetAgents[Team1].Length
        Team2 := TeamCollection.GetTeams()[1]
        set NumberPlayersTeam2 = TeamCollection.GetAgents[Team1].Length
    ):

    return

```

This will work only if you do not use specifiers that have rollback. Team 2 will only be updated occasionally because only one team can be on the map at a time. Just change the logic to what you want.

---

<div class="post-metadata">

**Author:** ![\_MMB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_MMB](https://forums.unrealengine.com/u/_MMB)\
**Post date:** [May 22, 2023, 5:57pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/5 "2023-05-22T17:57:08Z")

</div>

Thank you !

---

<div class="post-metadata">

**Author:** ![summergrrrl](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/summergrrrl/32/979572_2.png) [@summergrrrl](https://forums.unrealengine.com/u/summergrrrl)\
**Post date:** [May 24, 2023, 3:40pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/6 "2023-05-24T15:40:57Z")

</div>

Great question and responses here! I’d also recommend checking out the [Team Elimination Game tutorial](https://dev.epicgames.com/documentation/en-us/uefn/team-elimination-game-8-final-result-in-verse) which shows how to use the team APIs and handle player elimination and spawning as well.

---

<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:** [June 23, 2023, 3:41pm UTC](https://forums.unrealengine.com/t/verse-how-the-get-the-team-of-the-eliminating-player/1173650/7 "2023-06-23T15:41:43Z")

</div>

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