IndexOutOfRangeException: Array index is out of range

Hello Unity3D i have a problem with a script im using.The problem is i have a combo script and every time i do the combo it works out fine the first time.But when i try it again for the second time the combo doesn’t work and unity tells me"IndexOutOfRangeException: Array index is out of range.".Then when i do it the third time the combo works again.Does anyone know why this happens? If so can someone please tell me how i can fix this?I have been stuck on this for 2 months…

Heres the Script for visual aid

#pragma strict
var combos : ComboSequence[] = new ComboSequence[3]; //Combo class. Fill this out in Inspector.
var comboMaxTime : float = 1.0; //How long a timer for combo lasts in seconds. Fill this out in Inspector.
var comboSpanTime : float = .25; //The span of when a combo can start. Fill this out in Inspector.
var comboMidPoint : float = .5; //The position within the maxtime of a combo the span is active. Fill this out in Inspector.
private var currentCombo : int = -1;
private var comboTimeout : float = .0;
AudioListener.volume = 100;
function Update () {
    if (Input.GetKeyDown("k")) Attack();
    if (comboTimeout > 0) DecreaseTime();
function Attack () {
    ComboTime(); //Do all the logic for timing before animation etc.
    animation.Play(combos[currentCombo].comboAnimation); //Play the currentCombo combos' animation
    audio.clip = combos[currentCombo].comboSound; //Set the audio clip to the currentCombo combos' audio
    audio.Play(); //Finally play the audio
    audio.volume = 50;
    //Add logic for hitting enemies etc here!
function ComboTime () {
    if (currentCombo<combos.Length-1 && 
            comboTimeout>0 && 
            comboTimeout>comboMidPoint-comboSpanTime &&
            comboTimeout<comboMidPoint+comboSpanTime ||
            currentCombo==-1) {
    } else {
        currentCombo = -1;
    comboTimeout = comboMaxTime;
function DecreaseTime () {
class ComboSequence {
    var comboName : String; //A name for current attack (might be of use later for tutorial or something else)
    var comboAnimation : String; //The animation name for current attack
    var comboSound : AudioClip; //The audio for current attack

Well, you set your “currentCombo” to “-1” which is out of the arrays bounds since an valie indices goes from 0 to (array.Length-1) inclusive.

If you want to somehow “deactivate” the combo when setting it to -1, you have to prevent the code in Attack (and all other cases) from using currentCombo as index into an array if it’s value is -1.