Keeping distance between two gameObjects

I am trying to keep a certain distance between two gameobects. However, the current way that I am attempting to do it spits out an error:

InvalidCastException: Cannot cast from source type to destination type.
orbit.Update () (at Assets/Standard Assets/Scripts/AI/orbit.js:17)

I am currently using this script:

#pragma strict

var otherObject : GameObject;

var distance;
function Start () {


}

function Update () {
 distance = Vector3.Distance(this.transform.position, otherObject.transform.position);

 if(distance !=50) {
 Debug.Log(distance);
 distance = 50;
 transform.position = distance;
 }
 var somePos : Vector3 = otherObject.transform.position;
    transform.RotateAround (somePos, Vector3.up, 20 * Time.deltaTime);
}

My question is this: Am I doing this right and if so how do I fix the error, or am I just keeping the distance horribly?

Your problem is assigning a distance (scalar) to a vector. What you want to do is this:

  distance = 50;
  transform.position = (transform.position - otherObject.transform.position).normalized * distance + otherObject.transform.position;

This uses the vector from the other object and sizes it to the distance before adding it on to the other position.

Thanks, it works incredible.