Script not working, no compile errors...On Trigger Enter

I’m trying to get my enemy to attack me when it comes into contact with my player. Here is the script on the enemy: (Enemy has a collider and is ticked “trigger”) This enemy also has an AI script on it that makes it run towards the player… Could that be causing this??

var yourAnimation : String; ///I put "attack1" here and its attached to the zombie
 var zombie : GameObject; ////I put my zombie/enemy gameobject here....
  
 function OnTriggerEnter (Other : Collider){
  
 if(Other.gameObject.tag == "Player"){
  
 zombie.animation.Play("yourAnimation");
  
 }
  
 }

My Player has a collider attached without the “is trigger” box checked. My player is tagged PLayer. I also tried this the other way around to no avail. When my player comes into contact with the enemy it does not play the animation. Any ideas on my script?? Again I have no compile errors on runtime.

My Enemy AI script just in case its helps:

var Player : Transform;
 var MoveSpeed = 4;
 var MaxDist = 10;
 var MinDist = 5;
 
 
 
 function Awake(){
Player = GameObject.FindWithTag("Player").transform;
}

 function Start () 
 {
 
 }
 
 function Update () 
 {
     transform.position.y=-8.5;
     transform.LookAt(Player);
     
     
     if(Vector3.Distance(transform.position,Player.position) >= MinDist){
     
          transform.position += transform.forward*MoveSpeed*Time.deltaTime;
 
           
           
          if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
              {
                 //Here Call any function U want Like Shoot at here or something
    } 
    
    }
 }

As per the documentation, one of the collider gameobjects must have a rigidbody attached for trigger events to fire.

OnTriggerEnter

try replacing

zombie.animation.Play("yourAnimation");

with

zombie.animation.Play(yourAnimation);

Because in your code there was a string yourAnimation which actually is attack1 (this is your string’s value), but since you use “yourAnimation”, it’s not going to work because computer thinks that you are looking for animation called yourAnimation instead of an animation with name equal to the value of string yourAnimation