NullReferenceException: Object reference not set to an instance of an object

Hello,
So I was making a checkpoint or respawn point in unity 2D. when I die first time it works properly, but second time it shown an error “NullReferenceException: Object reference not set to an instance of an object”. The scripts code are her:


First Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RespawnScript : MonoBehaviour{

private GameMaster gm;

void Start() {
gm = GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>();
}
void OnTriggerEnter2D(Collider2D other) {

    if(other.gameObject.tag == "Player")
 {
 gm.lastCheckPointPosition = transform. Position; }
}}

Second Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerPos : MonoBehaviour
{
  private GameMaster gm;
void Start()
    {
        gm = GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>();
        transform.position = gm.lastCheckPointPosition;
    }

   void Update(){
        if(Input.GetKeyDown(KeyCode.Space)){
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            Debug.Log("Space pressed");
        }
    }
}

Third Script

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;

public class GameMaster : MonoBehaviour
{
    static GameMaster instance;
   [SerializeField]public Vector2 lastCheckPointPosition;

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

}

In your third script, try this on ln 15:

Destroy(gameObject);