Rotating Wrong

when the AI moves towards me it rotates forward for some reason, same as when it sees my player if I move it’ll tilt the model forward a little and then when he chases me it doesn’t work very well it just stays where it rotated to and ends up flipping everywhere, Ive added a ridgidbody… but it still hasn’t worked. Is they a way I can make it not rotate? I’ve froze the rotation using the ridgidbody.

My code is below.

var Distance;
var Target : Transform;
var lookAtDistance = 25.0;
var attackRange  = 15.0;
var moveSpeed = 5.0;
var Daping = 6.0;
var myTrans : Transform;

private var anim : Animator;

function Start () {
		anim = GetComponent(Animator);

function Update () 
			Distance = Vector3.Distance(Target.position, transform.position);
			if (Distance < lookAtDistance) 
				anim.SetBool("Walking", false);
				Debug.Log("Looking at Player!");
				lookat ();
			if (Distance > lookAtDistance)
				Debug.Log("Looking For Player!");
			if (Distance < attackRange)
				transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
				//anim.SetBool("Walking", true);

function lookat () {
	var rotation = Quaternion.LookRotation(Target.position - transform.position);
	transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Daping);

function attackPlayer () {
	//transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);

You’re pointing the object at the target transform in the lookat() method. Remove that code and it shouldn’t never rotate at all.