Audio Random Sounds Out Of Range Error?

Ok I’m trying to get a sound to play from an array. I want my sound to play using an animation even called from a C# script but I keep getting an error message saying:
IndexOutOfRangeException: Array index is out of range.

Here is what I have as my script set up:

//Random Clips
	public AudioClip[] VoiceClips;

public void KITTvoice01()
	{
		
		AudioSource.PlayClipAtPoint(VoiceClips[Random.Range (0, VoiceClips.Length)], Camera.main.transform.position);
	}

Not Correct, leaving for future readers

Should be VoiceClips.Length - 1, as VoiceClips[VoiceClips.Length] is in fact out of range because it’s 0 indexed :slight_smile: