MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.,

public class Player : MonoBehaviour
{
//Variables

//player

public float movementSpeed;
Animation anim;

public float attackTimer;
private bool moving;
private bool attacking;

//pmr
public GameObject playerMovePoint;
private Transform pmr;
private bool triggeringPMR;


// enemy
private bool triggeringEnemy;
private GameObject _enemy;

//Functions
void Start()
{
pmr = Instantiate(playerMovePoint.transform,this.transform.position,Quaternion.identity);
pmr.GetComponent().enabled = false;
anim = GetComponent();
}

void Update()
{
//Player movement
Plane playerPlane = new Plane(Vector3.up, transform.position);
Ray ray = UnityEngine.Camera.main.ScreenPointToRay(Input.mousePosition);
float hitDistance = 0.0f;

if(playerPlane.Raycast(ray,out hitDistance))
{
Vector3 mousePosition = ray.GetPoint(hitDistance);
if(Input.GetMouseButtonDown(0))
{
moving = true;
triggeringPMR = false;
pmr.transform.position = mousePosition;
pmr.GetComponent().enabled = true;
}
}

if(moving)
   Move();   
else
   {
     if(attacking)
        Attack();
     else
        Idle();   
   }

print(triggeringPMR);

if(triggeringPMR)
{
    moving =false;
}

if (triggeringEnemy)
Attack();

}

public void Idle()
{
    anim.CrossFade("idle");
}

public void Move()
{
transform.position = Vector3.MoveTowards(transform.position, pmr.transform.position,movementSpeed);
this.transform.LookAt(pmr.transform);

  anim.CrossFade("walk");

}

public void Attack()
{
    anim.CrossFade("attack");
    transform.LookAt(_enemy.transform);
}

 void OnTriggerEnter(Collider other)
 {
     if(other.tag == "PMR")
     {
         triggeringPMR = true;      
     }

     if(other.tag == "Enemy")
     {
         triggeringEnemy = true;
         _enemy = other.gameObject;
     }
 }

 void OnTriggerExit(Collider other)
 {
     if(other.tag == "PMR")
     {
         triggeringPMR = false;
     }
     if(other.tag == "Enemy")
     {
         triggeringEnemy = false;
         _enemy = null;
     }
 }

}
,

You are probably deleting the game object who’s transform you want to change. When you get this error message, check the hierarchy to see if the game object still exists.