Coin counter resets when character respawns

So I have this coins which have a counter widget. But everytime my character dies/respawns the counter resets back to 0. I do not want this to happen and I don’t know how to make it so it doesn’t reset? I know I’m destroying my actor with the coins then spawning a new one without coins. But I don’t have much knowledge on how to prevent that.
Would appreciate any possible help.

When you are destroying the actor and creating a new one, you are creating entirely different object that (values that stores are separate), just as if you would put your mug with coffee into a sink and pulled entirely new mug from the drawer.

If you want some data to persists, you could:

  1. store it in different object (e.g. gamo mode/state or instance)
  2. don’t destruct the actor
  3. or simply pass the necessary data to the new actor.

As for different object, Game mode/game state are level wide objects that are created at the beginning of the level and destructed at the end (be careful, game mode and game state are very different in multiplayer games). You could also store it in a game instance, which is persistent throughout the entire game, from launch through exit (even through different levels).

If you are making a singleplayer game and want the coins to persist only for the current level, I would add the coins to game mode