How to Make sure object only rotates in Y axis

Currently I have a script to allow my ‘monster’ to target the player, but currently I’m having trouble making sure my monster can only rotate around the Y axis. Here’s my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MonsterAI : MonoBehaviour {
	public Transform target;
	public Transform myTransform;
	public int MoveSpeed = 1;
	public int rotationSpeed = 3;
	// Use this for initialization
	void Start () {
		CharacterController controller = GetComponent<CharacterController> ();
		
	}

	// Update is called once per frame
	void Update () {
		//transform.LookAt (Player);

		myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
		myTransform.position += myTransform.forward * MoveSpeed * Time.deltaTime;
	}
}

Essentially I don’t want my monster to rotate when the player jumps into an awkward angle. Any help would be appreciated.

The code I was using to get that done, you can try it:

    void LookAt2D(Transform who, Transform target)
      {
        Vector3 dir = target.position - projectilemarker.position; // Projectile marker is the exact spot that we want to look from. You can delete that
        float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        who.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
      }

Well, I normally suggest using something like Quaternion.AngleAxis which takes angle and axis to rotate around which is y in your case. But if you want a little hack, try creating a look vector and set its y parameter to your objects forward vectors y.

Vector3 lookVector = target.position - myTransform.position;
lookVector.y = myTransform.forward.y;

this should cause your object to rotate around y axis relative to its current forward facing direction. Or set the y value to 0

Put a Rigidbody and fix the constraints in the X and Z axes and the character won’t rotate on the X and Z axes until forced to.