Why does this Script not work?

Basically this script measures the distance between the object it is placed on, and the player, when the player gets within a certain distance of the object you can click it certain things happen. currently it doesn’t measure the distance, however if i take the If statement and the actions outside of the update function the it measures the distance, but obviously then the if commands will not work. Pleas help

public var Portal:GameObject;
var Lever : Transform ;
var distance : float;
var Lever2 : GameObject;
var PickUpSound : AudioClip;
var audioVolume = 1.0;
var object1 : Transform;
var object2 : Transform;

function Update () {
	if (Input.GetButton ("Fire3") && (distance<60 )){
        distance = Vector3.Distance(object1.transform.position,object2.transform.position);
        audio.Play();
        Inventory.Lever1bool = true;
 	    Destroy(Lever2);
        yield WaitForSeconds(3);	 
   	    Instantiate(Portal, new Vector3(-75, 56, -28), Quaternion.Euler(0, 90, 0));
   	}	

}

You can’t use yield within an update function, this may be causing the problems you are having.

Create a new function to instantiate your portal object and call it from update when it is required.