companion follow broken

hi i made this script and i dont knolw what iv broken and i dont know hw to fix it
using UnityEngine;
using System.Collections;

public class FollowPlayer : MonoBehaviour {

public Transform target; 
public float moveSpeed = 3; 
public float rotationSpeed = 3; 
public float Distance;
public Transform myTransform ; 

void Awake(){
	myTransform = transform; 
}
void Start(){
	target = GameObject.FindWithTag("Player").transform; 
}

void Update () {
	if (Distance <= 5) {
		moveSpeed = 0;
	} else if (Distance >= 6) {
		var lookDir = target.position - myTransform.position;
		lookDir.y = 0; // zero the height difference
		myTransform.rotation = Quaternion.Slerp (myTransform.rotation,
			Quaternion.LookRotation (lookDir), rotationSpeed * Time.deltaTime);
		myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
	}
}

}

Whats the actual issue? Does it give you any syntax errors or just not work/do what its intended to when you test it?

Also, one thing iv noticed is the start of your if-statement, assuming that you dont have a value set for Distance, itll be defaulted to 0, therefore, your move speed will be set to 0.

If in your inspector, the “Distance” is set to a number greater than 6, you shouldnt have any problems, but at the same time, the else-if doesnt ever update or reset the moveSpeed, so if the game starts off at 0 Distance, and you later change that while the game is still running, the moveSpeed is still 0 since that was never influenced by anything else. Maybe in Start set the moveSpeed and then again in your else-if.