Verse code crash when player leaves

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.

1 Like

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{}

’ ’ ’

2 Likes

Any luck of fixing this yet?

1 Like

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.

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

@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?

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.