Problem with: IndexOutOfRangeException: Array index is out of range.

I have a dialog in the game (sentence per wav file) that I have put in array.

var sentence : AudioClip[];

function Update () 
{

	if (gameVariables.gamestate == 1) 
	
	{
		print(sentence.Length);	
		
		dialog ();		
		gameVariables.gamestate = 2;	
	
	}

}

function dialog ()

{

	audio.clip = sentence[0];

	audio.Play();

	yield WaitForSeconds (audio.clip.length);

	audio.clip = sentence[1];

	audio.Play();

	yield WaitForSeconds (audio.clip.length);

	audio.clip = sentence[2];

	audio.Play();

	yield WaitForSeconds (audio.clip.length);

}

At first this works fine. I can hear the sounds etc. But for some reason without me changing (at least that I know) anything it starst to suddenly say: “IndexOutOfRangeException: Array index is out of range.”.

I can see in the inspector that there are sounds. If I delete the gameobject that has this script, make a new one, it again works for some time. Couple of times that I run the game. Then stops working. Strange. Any ideas what I’m doing wrong here?

I also added the Debug "print(sentence.Length); " and it gives zero. That’s the problem but why is it suddenly giving zero since in the inspector it’s clear that there are wav files.

EDIT:

If I call this function from another gameobject it works again. But why? I have no idea.

var tarina = GameObject.FindWithTag("eventti");
tarina.GetComponent(eventsVillage).dialog ();

Do you have more than one game object with this script?

All game objects with this script attached has the array filled with at least 3 sounds?

Do you use Awake() and/or Start() to change the values in this array (or any other function for that matter)?