# I can't seem to add a value to the map type variable.

**URL:** <https://forums.unrealengine.com/t/i-cant-seem-to-add-a-value-to-the-map-type-variable/1145070>\
**Category:** Verse\
**Tags:** unreal-engine, unreal-editor-for-fortnite, fortnite\
**Created:** [April 26, 2023, 2:19pm UTC](https://forums.unrealengine.com/t/i-cant-seem-to-add-a-value-to-the-map-type-variable/1145070 "2023-04-26T14:19:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AddisonV](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/addisonv/32/642498_2.png) [@AddisonV](https://forums.unrealengine.com/u/AddisonV)\
**Post date:** [April 26, 2023, 2:19pm UTC](https://forums.unrealengine.com/t/i-cant-seem-to-add-a-value-to-the-map-type-variable/1145070/1 "2023-04-26T14:19:30Z")

</div>

So I have an verse script that is supposed to keep track of which checkpoint a player is on, and later respawn him in that checkpoint. But no matter what I do the map keeps being empty and no value is stored in it, so I can’t proceed with the respawn logic.

```auto

team1_manager := class(creative_device):

    @editable
    RaceCheckpoints : []race_checkpoint_device = array{}

    var PlayersRef : [player]int = map{}

    var Player1Checkpoint : []int = array{0}

    #var PTranslation : (vector3, vector3) = vector3.zero

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        Sleep(1.0)
        Print("Team1 Manager Started")
        AllPlayers := GetPlayspace().GetPlayers()
        for (TeamPlayer : AllPlayers, CurrentTeam := GetPlayspace().GetTeamCollection().GetTeam[TeamPlayer]):
            if(CurrentTeam = 1):
                if(set PlayersRef[TeamPlayer] = 0, Checkpoint := PlayersRef[TeamPlayer]):
                   Print("Player checkpoint is {Checkpoint}")

        for (players := 0..PlayersRef.Length):
            Print("Player {players} is on Team 1")
            Print("Player map size: {PlayersRef.Length}")

        for (Checkpoint : RaceCheckpoints):
            Checkpoint.CheckpointCompletedEvent.Subscribe(ClearedCheckpoint)
        #end for

    
    ClearedCheckpoint<private> (Agent : agent):void=
        #Print("Cleared Checkpoint")
        if(value := PlayersRef[Agent]):
            Print("Player Cleared {value} Checkpoints")
        else:
            Print("Player not in map, map size: {PlayersRef.Length}")
        for(Key -> Value : PlayersRef):
            Print("Key: player0 Value: {Value}")

            if (Key = player[Agent]):
                Translation := vector3
                index := 0
                if:
                    set Player1Checkpoint[Value] = Player1Checkpoint[Value] + 1
                    index = Player1Checkpoint[Value]
                    #set Translation = RaceCheckpoints[Player1Checkpoint[Index]].GetTransform().Translation
                    Rotation := RaceCheckpoints[Player1Checkpoint[Value]].GetTransform().Rotation
                #Respawn(Players, Translation, Rotation)
                Print("Checkpoint saved: {index}")
            #end if

```

When the game starts, sometimes it does’t even print the requested prints and when it prints, it says that a player is in team 1 but the Player map size is 0.

---

<div class="post-metadata">

**Author:** ![MattRix](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattrix/32/686548_2.png) [@MattRix](https://forums.unrealengine.com/u/MattRix)\
**Post date:** [April 27, 2023, 3:20am UTC](https://forums.unrealengine.com/t/i-cant-seem-to-add-a-value-to-the-map-type-variable/1145070/2 "2023-04-27T03:20:01Z")

</div>

You’re checking “if(CurrentTeam = 1)” which will never succeed, because CurrentTeam is an instance of the team class, not an integer like “1”. If you want to find the index of the team (and btw the first team is 0, not 1), after getting the CurrentTeam you’ll need to do `TeamIndex := GetPlayspace().GetTeamCollection().GetTeams().Find[CurrentTeam]`.

I recommend writing a line at the top of the OnBegin that’s something like `TC := GetPlayspace.GetTeamCollection()` so your code is easier to read and write.
