Help with Audio Fade

After spending an embarrassing amount of hours trying to figure out how to fade out an audio clip I finally concede my incompetence.
Would a kind soul give a helping hand please?

Simple script I have so far:

function Start() {
    // Get the object with the audio attached from main menu
    var menuMusic : GameObject = GameObject.Find("MenuMusic");
    if (menuMusic) {
        // Stop the menu music
		yield WaitForSeconds (4);
        Destroy(menuMusic);
    }
}

The object that has this script attached is not the object that has the audio source attached.

Have tried various scripts from related questions but I obviously dont seem to understand them enough to implement them.

Any help will be appreciated.

EDIT: Latest attempt below, still not working.

function Start() {
    // Get the object with the audio attached from main menu
    var menuMusic : GameObject = GameObject.Find("MenuMusic");
    if (menuMusic) {
        // Stop the menu music
		yield WaitForSeconds (4);
		FadeOutSound();
		print ("Get Fade Menu Music Function");
        //Destroy(menuMusic);
    }
}

function FadeOutSound(){

var i : int;

	for (i = 9; i > 0; i--)
	{
    	audio.volume = i * .1;
    	yield new WaitForSeconds (.5);
		print ("Fade Menu Music");
	}
}

In your script, fading out would start 4s after the object was created (the object containing the script). I suspect that’s not what you wanted, so I separated the fading function and did some modifications: you can drag the object containing the audio to the Inspector var menuMusic; when FadeOutSound is called, it will use this var if you’ve defined the object, otherwise it will search for a child object named MenuMusic. Anyway, it will wait for 4 seconds, then fades out the music in 4.5s.

You can call this function when a key is pressed, for instance:

function Update(){

  if (Input.GetKeyDown("F")){
    FadeOutSound();
  }
}

var menuMusic:GameObject;

function FadeOutSound(){
    if (!menuMusic){
      // Get menuMusic if not already defined in Inspector
      menuMusic = GameObject.Find("MenuMusic");
    }
    if (menuMusic) {
        // wait 4 seconds then fades for 4.5s
        yield WaitForSeconds (4);
        for (var i = 9; i > 0; i--){
          menuMusic.audio.volume = i * .1;
          yield new WaitForSeconds (.5);
          print ("Fading...");
        }
        menuMusic.audio.volume = 0;
    }
}

Here is a script from the forums: How To → Fade Out Music Before Loading Level

You should be able to implement that pretty easily. If you don’t need to load a level with your script, just remove the Application.LoadLevel(loadLevel); line.

For example:

function Start() {
    // Get the object with the audio attached from main menu
    var menuMusic : GameObject = GameObject.Find("MenuMusic");
    if (menuMusic) {
        // Stop the menu music
        FadeOutSoundAndLoadLevel(0);
    }
}

Just remove the Update() and OnGUI() methods.