Coin troubles part 2

This is a repost of a post I made around 6 hours ago since it go no responses. I just wanted to know two things. How can I make it so these coins only spawn once, despite me leaving the scene and coming back, and how to keep the coin counter the same despite leaving the scene and returning. Currently when I go from scene 1, to scene 2, I collect coins and the coin counter properly updates. However when I return to scene 1 it seemingly resets. Upon going back to scene 2 and collecting more coins however, the coin counter picks up where it left off. For example if I collect 5 coins and go back to scene 1, it will say i have zero. Then if i go back to scene 2 and collect 3 more, it will say I have 8. I currently have the coin counter as a global number variable.

Hi, please don’t make any reposts. I have already told you that in the other double posting you did. 6 hours are not really a long time to wait for a reply. I am going to close the other topic and keep this one open.

Whenever you want to track something across different scene you need global variables. Since you are not spawning your coins randomly you have to track for every single coin whether it has been already collected.

Like your health points and the health bar you have to set the coin counter at the beginning of your scene so that values are updated when you go back to scene 1.