Smooth look at on Y axis only

Hi guys, so Im trying to make a basic enemy AI, and Im using a kind of cone of vision. For that, I have a literal cone, set as a trigger, and I want to make it look towards the player when the player enters it. So far I’ve tried a few solutions, but its always messed up and just sent the cone in a completely random rotation. Here is my code so far-

#pragma strict
var SeenPlayer : boolean = false;
var target : Transform;

function Start () {

}

function Update () {
if (SeenPlayer == true){
//This is where I want it to look at the player 
}


}

function OnTriggerStay (other : Collider){
if (other.tag == "Player"){
SeenPlayer = true;
}
}

function OnTriggerExit (other : Collider){
if (other.tag == "Player"){
SeenPlayer = false;
}
}

In case it helps to know, by default my cone is 270, 315, 0.

Thanks guys

I’m assuming ‘target’ is a reference to the player:

  var dir = target.position - transform.position;
  dir.y = 0.0;
  transform.Rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(dir), Time.time * speed);

‘speed’ is a variable you define and is measured in degrees per second.