my distance code problem!!

I write this code but when run it get error and say you can’t have distance with game objects and when I change the all of Gameobjects to transform the transform.find can’t find any thing!!
var hSliderValue:int = 2;

    var MovingSpeed : int = 2;
	
	var Right : GameObject;
	
	var Left : GameObject;
	
	function Update () {
	
	Right = GameObject.Find("right");
	
	Left = GameObject.Find("left");
	
	if( GameObject.Find("right")){
	Debug.Log("find!!");
	}
	transform.Rotate(0,0,Input.GetAxis("Mouse X")*hSliderValue);
	
	transform.Translate(0,0,Input.GetAxis("Vertical")*MovingSpeed*Time.deltaTime);	  
      
  //compute the right hand side distance
    
    var Rdist = Vector3.Distance(Right.position, transform.position);
   
     if ( Rdist < 0.0645 && Input.GetAxis("Vertical")<0){
   
     MovingSpeed = 0;
    }
    else{
  //compute the left hand side distance 
    
    var Ldist = Vector3.Distance(Left.position, transform.position);
  
    if ( Ldist < 0.670 && Input.GetAxis("Vertical")>0){
   
    MovingSpeed = 0;
    }
    else{
    
    MovingSpeed = 2;
    }
    } 
   }

help me please :frowning:

I find the answer thanks from friends!!
I should change variables like this:

  var Right : Transform;
  var Left : Transform;
  Right = GameObject.Find("right").transform;
 
  Left = GameObject.Find("left").transform;