Turret Shooting

I’m making a turret in my game and I want it to rotate 180 degres while shooting at me I have a machine gun script:

var fireRate : float = 0.1;
var Prefab: Transform;
private var nextFire = 0.0;
var speed : float = 50;
function Update () {
    if(Input.GetKey("mouse 0")&&Time.time > nextFire){
    nextFire = Time.time + fireRate;
    var copy = Instantiate(Prefab,GameObject.Find("spawnPoint").transform.position,transform.rotation);
    copy.rigidbody.velocity = transform.TransformDirection(Vector3.forward * speed);

}

}

a regular gun script:

var fireRate : float = 0.1;
var Prefab: Transform;
private var nextFire = 0.0;
function Update () {
    if(Input.GetKeyDown("mouse 0")&&Time.time > nextFire){
    nextFire = Time.time + fireRate;
    var copy = Instantiate(Prefab,GameObject.Find("Spawn Point").transform.position,transform.rotation);
    copy.rigidbody.velocity = transform.TransformDirection(Vector3.forward * 100);

}

}

I tried altering both but I cant figure out how to make a turret script. Thanks in advance!

transform.LookAt(player.position);

if (Time.time > nextFire) Fire();

Not sure what you mean by 180*, but if you mean to limit the object’s rotation you’ll need to do logic after the LookAt to constrain the rotation’s euler angles.