Function Update not working

I have a javascript that is supposed to let you pickup a battery but other stuff happens but when the script gets to the function update, i get errors. Can someone PLEASE help

var monster : GameObject;
var SoundObject : GameObject;
var MeshObject : GameObject;
var playerTag = "Player";
var buttonInRange;
private var hasPlayed = false;


function OnTriggerEnter (c : Collider)
{

buttonInRange = true;
}

function OnTriggerExit (c : Collider)
{
	buttonInRange = false;

}

function OnGUI ()
{
	if(buttonInRange == true)
	{
		
		GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50), "Pick up batteries");
	
}
 function Update ()
{
	if (buttonInRange == true)
	{
		if (Input.GetKeyDown ("e"))
		{
			if(!hasPlayed)
			{
             MeshObject.GetComponent.<MeshRenderer>().enabled = false;
             yield WaitForSeconds(0.5);
             SoundObject.active = true;
             yield WaitForSeconds(2.5);
             monster.active = true;
             SoundObject.active = false;
             hasPlayed = true;
             Destroy(gameObject);
        	}
          }
         }
       }

You can’t have yield WaitForSeconds in a function, it needs to be in a coroutine.

IEnumerator Example() 
     {
         if (buttonInRange == true)
         {
             if (Input.GetKeyDown ("e"))
             {
                 if(!hasPlayed)
                 {
                  MeshObject.GetComponent.<MeshRenderer>().enabled = false;
                  yield WaitForSeconds(0.5);
                  SoundObject.active = true;
                  yield WaitForSeconds(2.5);
                  monster.active = true;
                  SoundObject.active = false;
                  hasPlayed = true;
                  Destroy(gameObject);
                 }
               }
              }
            }

But since you need this checked every frame add this before it.

Function Update()
{
     StartCoroutine("Example");
}

This should work please let me know if this helped you!