Assign AFK Players to a Team After Delay and Teleport All Players to Team Bases (UEFN Verse)

Hi everyone,

I’m trying to build the following system in UEFN using Verse, but I keep running into API issues with fort_team_collection.

Current Setup (working without Verse):

  • Players enter a Mutator Zone.

  • A Class / Team is assigned via devices.

  • A Teleporter sends them to a waiting area.

  • Everything up to this point works perfectly using devices only.

What I want to achieve with Verse:

  1. When the game starts, start a 20-second timer.

  2. After 15 seconds:

    • Any AFK player (who did not choose a team) should automatically be assigned to a default team.
  3. After 20 seconds:

    • ALL players should be teleported to their respective team base.

Problem:
I am having trouble correctly:

  • Detecting whether a player is already on a team

  • Assigning a team via fort_team_collection

  • Determining which team a player belongs to (without using non-existent functions like GetTeamIndex)

  • Handling decides functions correctly in failure contexts

I tried using:

  • GetTeam[]

  • GetTeams[]

  • AddToTeam[]

  • IsOnTeam[]

But I keep running into issues like:

  • Unknown member errors

  • Incorrect failure context usage

  • No clear way to determine team index reliably

My Question:
What is the correct and clean way in Verse to:

  • Detect if a player has no team

  • Assign them to a default team after a delay

  • Then teleport players based on their team

Is there an officially recommended pattern for this?

I want to keep the device-based team selection system and only use Verse for the timed logic.

Thanks in advance!

Hey @Lutsch_mein_Ei how are you? Welcome to the forum!

First of all, what I would do is to place every player in a dummy team. Then check who is still in that dummy team after 15 secconds and sed them to an AFK team, and then send all the players to their corresponding areas (including the players in the AFK team).

To do that, you will need to setup your island first.

  1. Go to your island settings and set your teams to be exactly two more than the number of teams you want to be playing (if you will have 4 playable teams, set 6)

  2. Put a Teleporter device on each spawning area, and set them with the corresponding team index.

  3. Add two different timers (one for the 15 seconds count, and one for the 20 secconds count)

After that, you will need to create a device with the following code (you have a lot of comments in the code, which explains how it works):

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Fortnite.com/FortPlayerUtilities }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Random }
using { /Verse.org }

# A Verse-authored creative device that can be placed in a level
start_sequence_device := class(creative_device):

    # Primary game start timer
    @editable
    var MyTimer : timer_device = timer_device{}

    # Duration before the match actually starts
    @editable
    MyTimerDuration : float = 20.0

    # Auxiliary timer used to detect AFK players
    @editable
    var MyTimerAux : timer_device = timer_device{}

    # Time players have to move before being considered AFK
    @editable
    MyTimerAuxDuration : float = 15.0

    # Index of the "holding" or "dummy" team where all players are placed initially
    @editable
    DummyTeamIndex : int = 4

    # Index of the team where all AFK players will be placed after the auxiliary timer finishes
    @editable
    AFKTeamIndex : int = 3

    # Teleporters mapped by team index (Team 1 -> index 0, Team 2 -> index 1, etc)
    @editable
    TeamTeleporters : []teleporter_device = array{}

    # Cached spawn location if needed later
    var SpawnLocation : vector3 = vector3{}


    # Runs when the device starts during a running match
    OnBegin<override>()<suspends>:void=
        # Move all existing players to the dummy team at match start
        AllPlayers := GetPlayspace().GetPlayers()
        for (Player : AllPlayers):
            ChangePlayerTeam(Player, DummyTeamIndex-1)

        # Start both timers
        StartTimers()

        # When main timer ends -> teleport players to their team bases
        MyTimer.SuccessEvent.Subscribe(TeleportPlayers)

        # When auxiliary timer ends -> move AFK players to AFK team
        MyTimerAux.SuccessEvent.Subscribe(AFKTeamAssignment)


    # Starts both the match start timer and AFK detection timer
    StartTimers(): void=
        # Configure and start main match start timer
        MyTimer.SetMaxDuration(MyTimerDuration)
        MyTimer.Start()

        # Configure and start AFK detection timer
        MyTimerAux.SetMaxDuration(MyTimerAuxDuration)
        MyTimerAux.Start()


    # Changes a single player's team using the team collection
    ChangePlayerTeam(Player : player, NewTeamIndex : int) : logic =
        if:
            # Retrieve all teams available in the current playspace
            TeamCollection := GetPlayspace().GetTeamCollection()
            Teams := TeamCollection.GetTeams()

            # Validate the requested team index exists
            NewTeamIndex >= 0
            NewTeamIndex < Teams.Length

            # Select the team to assign
            NewTeam := Teams[NewTeamIndex]
        then:
            # Attempt to assign player to the selected team
            if(TeamCollection.AddToTeam[Player, NewTeam]):
            true
        else:
            false


    # Moves any players still in the dummy team into the AFK team
    AFKTeamAssignment(Agent:?agent) : void =
        # Access team collection
        TeamCollection := GetPlayspace().GetTeamCollection()

        # Get all teams in the match
        Teams := TeamCollection.GetTeams()

        # Retrieve dummy team using configured index
        if(DummyTeam := Teams[DummyTeamIndex-1]):

            # Get all agents currently in the dummy team
            if(DummyTeamPlayers := TeamCollection.GetAgents[DummyTeam]):
                # Loop each player and move them to AFK team
                for (PlayerAgent : DummyTeamPlayers):
                    if(Player := player[PlayerAgent]):
                        ChangePlayerTeam(Player, AFKTeamIndex-1)

    
    # Teleports all players to the teleporter corresponding to their team index
    TeleportPlayers(Agent : ?agent):void=
        AllPlayers := GetPlayspace().GetPlayers()
        TeamCollection := GetPlayspace().GetTeamCollection()
        Teams := TeamCollection.GetTeams()

        for (Player : AllPlayers):
                if(PlayerTeam := TeamCollection.GetTeam[Player]):

                    # Find index of the player's team inside the teams array
                    for (Index -> T : Teams):
                        if (T = PlayerTeam):
                            PlayerTeamIndex := Index

                            # If a teleporter exists for that team, teleport the player
                            if (Teleporter := TeamTeleporters[Index]):
                                Teleporter.Teleport(Player)

Save and compile that code, and then place the new custom device on your island.

Now, click on your device and start the setup. You should have something like this:

As you can see, you can manage the timers duration from here. The same with the dummy and afk teams.

Some clarifications regarding the teams and teleporters:

  1. Dummy Team and AFK Team should be the last two teams of your island (if you have 4 playable teams, 5 and 6 should be Dummy and AFK)

  2. The teleporters should be added to the array in the correct order! Being the first one for Team 1, the second one for Team 2, and so on.

And with that you will have the functionality you are looking for!

Let me know if you have any doubt or need more help!

1 Like