Counter resets after death?

I ran into a big problem I cannot solve.
I made a counter that goes up once a certain item is picked up in-game. Once a certain amount is collected the game ends. My problem is that once my player pawn (using basic car game template) dies and respawns the counter is reset back to 0. I tried to put the counter into the level, but learned you cannot cast to level BPs. I tried storing the counter in the game mode but did not work. I also learned that casting actors inside widgets don’t work that well. At least with something that is not player specific or game mode.

How would I fix this where the counter would not reset after dying?

I am struggling to figure this out. Any help is appreciated. Thanks!

Try utilizing the variable within GameState.

from the sound of it your counter isnt being reset, your character is being destroyed by the sound of it then your spawning in a new character. if thats the case then you need to save your counters value to a actor/object that isnt being destroyed prior to destroying your character. the game instance would probably be a good place for that depending on the situation. if however the counter is only relevant in the current level your playing then you may also wish to save the value to the game mode or player controller.

an alternative method you could also try would be to not destroy your character but rather disable its visibility then move it to the respawn point then make it visible again.

I will second this.