How do i make my enemy look at player on only one axis?

I am trying to make it so that the enemy looks at the player and I have achieved that but when I jusp it also rotates to the point where it is lying down if it is close up. How do I make it so that it will always stay upright and not “fall over” like it s doing?
Here is my current code attacked to the enemy:

void Update() {
Quaternion rot = Quaternion.LookRotation (player.transform.position - transform.position);
transform.rotation = Quaternion.Slerp (transform.rotation, rot, 1);
}

If you do not wish to worry about the Y axis you can just override the Y value of the calculation with the Y value from the enemy. So for example:

    void Update() {
        Vector3 lookVector = player.transform.position - transform.position;
        lookVector.y = transform.position.y;
        Quaternion rot = Quaternion.LookRotation(lookVector);
        transform.rotation = Quaternion.Slerp(transform.rotation, rot, 1);
    }

This will cause the ‘enemy’ to only rotate to face the players position on the X and Z planes and ignore the height.