# Verse code crash when player leaves

**URL:** <https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fortnite\
**Created:** [August 14, 2024, 3:20pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712 "2024-08-14T15:20:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![WolfyGamingWorld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WolfyGamingWorld](https://forums.unrealengine.com/u/WolfyGamingWorld)\
**Post date:** [August 14, 2024, 3:20pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/1 "2024-08-14T15:20:54Z")

</div>

I have a very easy and simple money and weapon storage system on my map with persistent save data across multiple sessions which is precisely as I’ve aimed to achieve, but whenever a player leaves the game my verse code crashes effectively ruining the game for everyone still in the game. This is a big problem for my game right now. Reference code below:

‘’'OnPlayerRemoved(PlayerLeft : agent): void = {  
if (Agent := agent[PlayerLeft]) {  
if (ActualPlayer := PlayerMap[Agent]) {  
var TempPlayerMap : [agent]spawners = map{}

```
            for (Key -> Value : PlayerMap) {
                if (Key <> Agent) {
                    set TempPlayerMap = ConcatenateMaps(TempPlayerMap, map{Key => Value})
                }
            }
        set PlayerMap = TempPlayerMap
        }
    }
}'''

```

If need be I can share more code surrounding it, but I believe I am missing something necessary to allow players to leave without the verse code crashing.

---

<div class="post-metadata">

**Author:** ![WolfyGamingWorld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WolfyGamingWorld](https://forums.unrealengine.com/u/WolfyGamingWorld)\
**Post date:** [August 16, 2024, 1:42pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/2 "2024-08-16T13:42:10Z")

</div>

This is my latest attempt and it still doesn’t work at all:

’ ’ ’

OnPlayerRemoved(OutPlayer:player):void=  
if:  
OutPlayer.IsActive  
set Data[OutPlayer] = player\_data{}

’ ’ ’

---

<div class="post-metadata">

**Author:** ![Dulitra](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dulitra](https://forums.unrealengine.com/u/Dulitra)\
**Post date:** [August 16, 2024, 5:00pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/3 "2024-08-16T17:00:17Z")

</div>

Any luck of fixing this yet?

---

<div class="post-metadata">

**Author:** ![WolfyGamingWorld](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WolfyGamingWorld](https://forums.unrealengine.com/u/WolfyGamingWorld)\
**Post date:** [August 17, 2024, 10:26am UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/4 "2024-08-17T10:26:05Z")

</div>

No man I’ve been working on it practically around the clock the past week an still no luck.

If anyone finds a solution please help us out because I’m seeing a lot of views on this post I’m sure many people are dealing with this issue.

---

<div class="post-metadata">

**Author:** ![Benjf29](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benjf29/32/1204359_2.png) [@Benjf29](https://forums.unrealengine.com/u/Benjf29)\
**Post date:** [August 19, 2024, 8:30pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/5 "2024-08-19T20:30:22Z")

</div>

Are you sure that’s the code who crash the game? No any loop without IsActive check ?

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [August 28, 2024, 9:57pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/6 "2024-08-28T21:57:12Z")

</div>

@WolfyGamingWorld Hi there! When you say the “Verse code crashes”, do you mean that you see a runtime error occur, or something else? If so, could you please provide the ID of the report? (You can see if your island has experienced runtime errors in the Creator Portal, by navigating to the Technical tab). If not, could you describe what you mean by a “crash” and how it manifests? i.e. Does the server crash for everyone in the game?

Could you also provide the island name/ID as well so that we can take a look internally to see if we have any data regarding what you’re experiencing?

---

<div class="post-metadata">

**Author:** ![LotusCracker](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lotuscracker/32/635286_2.png) [@LotusCracker](https://forums.unrealengine.com/u/LotusCracker)\
**Post date:** [September 19, 2024, 7:27pm UTC](https://forums.unrealengine.com/t/verse-code-crash-when-player-leaves/1975712/7 "2024-09-19T19:27:06Z")

</div>

Hey so we have similar issues in our project, as soon as a player leaves the game breaks and throws these errors:

## ErrRuntime\_WeakMapInvalidKey

c8810aae0e59d6df14349ff44e8a4ffa  
Modul(e): 21883214-4c18-2403-6b3a-e1bffb33121d v208  
Verse unrecoverable error: ErrRuntime\_WeakMapInvalidKey: Invalid key used to access persistent `var` `weak_map`. (Invalid key used to access persistent `var` `weak_map`.) Truncated callstack follows: rbfg:(/tohodev@fortnite.com/rbfg:)AddLifetimeWin(:agent) (Unknown source) (Source: Unknown(0,0, 0,0)) ScoreUI:(/tohodev@fortnite.com/rbfg/ScoreUI:)AwardEndGame(:agent,:agent) (Unknown source) (Source: Unknown(0,0, 0,0)) ScoreUI:(/tohodev@fortnite.com/rbfg/ScoreUI:)AwardWinnersAndLoosers (Unknown source) (Source: Unknown(0,0, 0,0)) task\_ScoreUI$OnBegin:Update (Unknown source) (Source: Unknown(0,0, 0,0))

Project name and id:  
rbfg  
(d0102f17-47d0-091c-c2e2-73b59961e4a2)

we are also using .IsActive() for every data call but it doesnt prevent the data from beeing checked it seems.
