Currency System Not Saving!?

Here’s the situation and an example of the problem with my currency system (all in C#). I plan for the player to be able to purchase upgrades between levels if they have enough gems.

Level 1: Player collects 100 gems. (100 gems is saved in PlayerPrefs).

Level 2: Player collects 50 gems. (150 gems saved in PlayerPrefs). So currency DOES save between levels.

However, I have only created 2 levels so far and I have made the player go back to the splash screen at the end of level 2. In which case, when the player reloads Level 1, the gem count is saved and loaded (via PlayerPrefs) but the Gem objects in the level reload - so the player can collect infinite gems. I have set the Gems to be destroyed on touching the Player. Once the gem has been destroyed in-game, I want it to permanently be destroyed (unless the player resets their current save) so the player can only gain the maximum number of gems in any given level.


Here is the Gem script and the relevant excerpt from the Player script.

void OnTriggerEnter(Collider c)
	if(c.gameObject.tag == "Player")


void Awake () {
                  Load ();
    void Save ()
    		PlayerPrefs.SetInt("Gems Currency",Gems);

void Load () {

Gems = PlayerPrefs.GetInt("Gems Currency");


It saves at the end of every level. Hope I’ve made this question clear enough. If you need more information, please let me know and I can make a video to better explain the problem. Hope somebody can help, major sticking point here!


So the best way to do this is to create a unique ID for each gem in a script and have that be auto destroyed if it has already been collected by saving away the ids.

That’s pretty easy to do like this, you would add this script to the gems:


  using System.Collections;
  using UnityEngine;

  public class OnlyUseOnce : MonoBehaviour {

          public string uniqueId;

          void Awake() {
                uniqueId = string.IsNullOrEmpty(uniqueId) ? System.Guid.NewGuid().ToString() : uniqueId;
                if(Application.isPlaying && PlayerPrefs.GetInt("USED_" + uniqueId, 0) == 1) {

          public void UseMe() {
                 PlayerPrefs.SetInt("USED_" + uniqueId, 1);


Now rather than Destroying the gem when the player picks it up you use: