# how to setup 2 team balancing?

**URL:** <https://forums.unrealengine.com/t/how-to-setup-2-team-balancing/1600438>\
**Category:** Programming & Scripting\
**Tags:** team, unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [January 8, 2024, 11:59pm UTC](https://forums.unrealengine.com/t/how-to-setup-2-team-balancing/1600438 "2024-01-08T23:59:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xTommi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/0xtommi/32/881018_2.png) [@0xTommi](https://forums.unrealengine.com/u/0xTommi)\
**Post date:** [January 8, 2024, 11:59pm UTC](https://forums.unrealengine.com/t/how-to-setup-2-team-balancing/1600438/1 "2024-01-08T23:59:57Z")

</div>

**introduction to the problem**  
so i have a huge problem with team balancing in my game, there should be 2 teams with 2 different class and a balanced numbers of players in each team so with a 1:1 ratio

**setup in my map:**

- island settings  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/7/b4715e0200d8a2f7548e2fd2b1f816c71345d843.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/9/42938ac417e76e1c2662885314fffe9978f45d24.png)

- spawn pads for the 2 teams  

- the 2 team settings in witch i only changed the name and set the class 2 on team 2  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/9/f39f77084a79fe97df3c59ed6543ccdca54b2ef7.png)

-the class 2 designer  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/5/bd5fd15767e5dc84ccdfda6af8ac40800db395e1.png)

-this verse script from the official documentation

```auto
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

tim_balance := class(creative_device):
        # Holds the teams found with GetTeams()
        var Teams : []team = array{}
        OnBegin<override>()<suspends> : void =

            Print("Verse Device Started!")
            set Teams = Self.GetPlayspace().GetTeamCollection().GetTeams()
            AllPlayers := GetPlayspace().GetPlayers()
            #Subscribe to PlayerAddedEvent to allow team rebalancing when a new player joins the game
            Self.GetPlayspace().PlayerAddedEvent().Subscribe(OnPlayerAdded)
            Print("Beginning to balance teams")
            BalanceTeams()

        #Handles a new player joining the game

        OnPlayerAdded(InPlayer : player) : void =
            Print("A new Player joined, assigning them to a team!")
            BalanceTeams()            

        <#
        For each player, find the number of players of the team they're on. Iterate through the
        list of teams and assign them to the team with the least amount of players, or their
        starting team in case of ties.
        #>

        BalanceTeams() : void =
            AllPlayers := GetPlayspace().GetPlayers()
            for (TeamPlayer : AllPlayers, CurrentTeam := GetPlayspace().GetTeamCollection().GetTeam[TeamPlayer]):
                # Assign Players to a new team if teams are unbalanced
                var TeamSize:int = 0

                if(set TeamSize = GetPlayspace().GetTeamCollection().GetAgents[CurrentTeam].Length):
                    Print("Size of this player's starting team is {TeamSize}")

                SmallestTeam : ?team = FindSmallestTeam(TeamSize)
                if (TeamToAssign := SmallestTeam?, GetPlayspace().GetTeamCollection().AddToTeam[TeamPlayer, TeamToAssign]):
                    Print("Attempting to assign player to a new team")

        FindSmallestTeam(CurrentTeamSize : int) : ?team =
            var SmallestTeam : ?team = false
            var TeamSize : int = CurrentTeamSize

            <#
            For each team Team, get the number of players on that team. If it has less players than SmallestTeam,
            set SmallestTeam to Team and update TeamSize to the number of players on the new Team
            #>

            for(Team : Teams, CandidateTeamSize := GetPlayspace().GetTeamCollection().GetAgents[Team].Length, TeamSize > CandidateTeamSize):
                set SmallestTeam = option{Team}
                set TeamSize = CandidateTeamSize
                Print("Found a team with less players: {CandidateTeamSize}")
            return SmallestTeam

```

**problem**  
when i test the map i spawn as team 2 with the team 1 class in the team 1 spawner  
and when i tested the map with friends actually 2 people from the same team got spawned in the same theam spawner

---

<div class="post-metadata">

**Author:** ![xxTESCHIO81xx1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xxTESCHIO81xx1](https://forums.unrealengine.com/u/xxTESCHIO81xx1)\
**Post date:** [March 29, 2026, 11:32pm UTC](https://forums.unrealengine.com/t/how-to-setup-2-team-balancing/1600438/2 "2026-03-29T23:32:01Z")

</div>

Hi, I’ll leave you a detailed guide, I hope it solves the problem

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/7/07768800cf271eec87eda36cf17465e8c0e756aa.jpeg "Unreal Engine 5.7: Automatic Team Balance System (No Widgets) | IGAME Series #3") ](https://www.youtube.com/watch?v=qzoqpe2Xbic)
