aim at an object that approches

how do i make a turrent aim at an object?
and on top of that how do you make the turrent look when the player approches?

Try using transform.LookAt which will rotate the object in the direction of a given target

http://unity3d.com/support/documentation/ScriptReference/Transform.LookAt.html

You can use transform.LookAt(target) to make the turret point to the target transform, and the target may be set in the Inspector or at Start with FindWithTag:

var target: Transform; // drag target here or let Start find it
var range: float = 25; // distance the target can be found

function Start(){
  if (!target){
    target = GameObject.FindWithTag("Player").transform; 
  }
}

function Update(){
  if (Vector3.Distance(target.position, transform.position) < range){
    transform.LookAt(target);
  }
}

NOTE: You must tag the target as “Player” if you want Start to find it automatically.