Variable resets after scene is reloaded

I’m creating a game where the player can collect “life points” so when the player dies, they can be “revived”. However whenever the scene is reset, the variable that determines the amount of extra lives they have resets.

This is the code that controls it

    private static GameMaster instance;

    public int numOfLives;
    public Vector2 lastCheckPointPos;

    private void Awake()
    {
        if(instance == null)
        {
            instance = this;
            DontDestroyOnLoad(instance);
        }
        else
        {
            Destroy(gameObject);
        }
    }

    public void IsPlayerDead()
    {
        if (numOfLives > 0)
        {
            numOfLives--;
            FindObjectOfType<GameManager>().Revive();
        }
        else if (numOfLives == 0)
        {
            FindObjectOfType<GameManager>().GameOver();
        }
    }

    public void IncreaseLives()
    {
        numOfLives++;
    }

The “life point” calls the funtion IncreaseLives when collected.

Any help would be greatly appreciated!

I also run into similar issue. What I think happens:

1. Load scene for the first time:
	1.1 A new instance of GameMaster is created (we will call inst0)
	1.2 inst0.Awake(), and set the static instance = inst0

2. Scene is reloaded:
	2.1 A new instance of GameMaster is created (we will call inst1)
	2.2 inst1.Awake(), and call Destroy(this.gameObject), which set a flag for itself to be destroyed
		2.2.1 NOTE: itself is NOT YET destroyed
		2.2.2 Briefly, we have 2 instances: inst0, inst1
	2.3 Somewhere else in your code, you call FindObjectOfType<GameManager>(), which might return inst1
		2.3.1 since inst1 just initiated, all variables are default (in your words "reset")
	2.4 Destroy flag now destroy inst1

If you put Debug.Log(FindObjectsOfType<GameManager>().Length) where you would have called FindObjectOfType<GameManager>() (step 2.3), you will see that it returns 2

A solution is to make all variables static. Since GameMaster is supposed to be Singleton anyway, making all variable static make sense. Then during that
brief period (step 2.1 to 2.4), even if there are 2 instances, they both access the same static variables;