Enemy behavior not working correctly

So what’s going on is I have a sphere collider trigger around the enemy, and when the player enters that, the enemy is supposed to chase the player until they either outrun the enemy (exiting the trigger) or hide. I’m working on the chasing when the trigger is entered. Here’s what I have for it:

public var enemyIdle : AnimationClip;
public var enemyWalk : AnimationClip;
public var enemyRun : AnimationClip;
public var enemyAttack : AnimationClip;
public var enemyKill : AnimationClip;
var MoveSpeed : float = 3;
var Player : Transform;
var MaxDist = 10;
var MinDist = 5;
 
 
function OnTriggerStay (other : Collider) 
{
   transform.LookAt(Player);
 
 
   if(Vector3.Distance(transform.position,Player.position) >= MinDist){
         transform.position += transform.forward*MoveSpeed*Time.deltaTime;
 
    }
    }

What’s happening instead is the enemy is chasing the player the entire time, not just when she enters the trigger. If I change it to OnTriggerEnter, the enemy doesn’t follow the player at all.
How can I get this to work correctly?

This happens because you need a if statement inside the OnTriggerStay. Add a tag to the player named Player or something and do

function OnTriggerStay (other : Collider) {
  if(other.gameObject.tag == "Player"){
     //Chase player
  }
}

if you do not do this, OnTriggerStay will be called if the trigger hits ANYTHING, even the terrain.