# Iterate through custom map does not work

**URL:** <https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 18, 2023, 10:44pm UTC](https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524 "2023-05-18T22:44:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CascadeSolutions](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cascadesolutions/32/702395_2.png) [@CascadeSolutions](https://forums.unrealengine.com/u/CascadeSolutions)\
**Post date:** [May 18, 2023, 10:44pm UTC](https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524/1 "2023-05-18T22:44:21Z")

</div>

I have a class called “gungame\_player”  
This class has an Attribute “Name”

```auto
gungame_player<public> := class():
    var Score : int = 0
    var Setbacks : int = 0
    var Kills : int = 0
    var Killstreak : int = 0
    var Name<public> : string = ""
    var UIButton : button_loud = button_loud{}

    Player<public> : player
    GungameManager<public> : game_manager_device
    FortChar<public> : fort_character
    Bots<public> : []sentry_device
    Agent<public> : agent

```

in my Game manager, i have a map containing several Gungame Players

```auto
 var Players : [agent]gungame_player = map{}

```

When i log the length of the Players array, i get 1 (Which is correct, as i am the only player there)

But when i want to iterate through the Map and output the Name, i get an error

```auto
 for(Key->Value : Players):
    Print("Test {Value.Name}")

```

This is the error:

```auto
Unknown(1,1) 2023.05.18-22.12.41:816:[VerseRuntimeErrors] Internal error encountered.

```

Vs code shows me, that Key is an `agent` type and Value is `gungame_player`

Should’t i be able to access the name then ?

---

<div class="post-metadata">

**Author:** ![Patothief](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Patothief](https://forums.unrealengine.com/u/Patothief)\
**Post date:** [May 19, 2023, 7:27pm UTC](https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524/2 "2023-05-19T19:27:30Z")

</div>

Guessing it’s not the variable name “Name” conflicting with something? Tried renaming it?

---

<div class="post-metadata">

**Author:** ![CascadeSolutions](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cascadesolutions/32/702395_2.png) [@CascadeSolutions](https://forums.unrealengine.com/u/CascadeSolutions)\
**Post date:** [May 23, 2023, 12:22pm UTC](https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524/3 "2023-05-23T12:22:55Z")

</div>

I found out, that on setting a new player inside the array, the player was not set and the value was basically “None”.

So although the length of the Array was 1, there was no real player inside it

---

<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 22, 2023, 12:23pm UTC](https://forums.unrealengine.com/t/iterate-through-custom-map-does-not-work/1170524/4 "2023-06-22T12:23:29Z")

</div>

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