How do we remove player stats from weak map

If you don’t want to save player data between sessions or rounds you should use a normal map. But if you want to use a weak_map you can something like this should work

OnPlayerRemoved(OutPlayer:player):void=
            if:
                OutPlayer.IsActive[]
                set YourWeakMap[OutPlayer] = player_stats_table{}

You cannot concatenate a weak map so removing a key will not work you can also not loop over a weak map but you can remove the data by just constructing a new class or data type and basically reset the stats and then set the player data to the new created class/data type. OutPlayer.IsActive is also important because if you don’t have it, it can throw a verse runtime error.

If you wanna store data between sessions and round check out this page Using Persistable Data in Verse | Unreal Editor for Fortnite Documentation | Epic Developer Community

1 Like