How I can make my Object Lookat the player and rotate only in two axis.

Okay so i was making an AI script for my enemy i used this line to make the enemy look and follow the Player.

transform.LookAt(Player);

but it rotates the enemy in Y axis too and its not what i want.
I want it to rotate only in X and Z axis while following the Player.

You must do it yourself. LookAt will use all axis.

    Vector3 direction = (player.transform.position - transform.position);
    direction.y = 0;

    transform.rotation = Quaternion.LookRotation(direction);

I have already figured it out.
But i have another problem now
i want my character to use the punch animation on colliding with the player but its not working this is the script

var Myself : Transform;
var AttackorNot : int;
function Update () {

          if(AttackorNot == 1){
             Myself.animation.CrossFade("punch");
            }
    
    }

function OnTriggerEnter(other:Collider){
   
   
       if(other.gameObject.CompareTag("Player"))
   {

      AttackorNot = 1;

   }
}

Myself is the main object which have this trigger
so i set this boolean function that if it will collide with the player the boolean will be 1
and in the update function i used this boolean function to run the animation on the main Object.

its not working.
whats wrong in it?