Array Index out of range?

enter code hereI’m quite confused by this little issue. I’ve dealt with arrays and classes before, but clearly I’ve made some sort of mistake. I keep getting Array Index is out of range on the line:

Equip(AllSkills[0],0);

AllSkills, the Array of the class “Skill” has members in it… as does SkillSlot(Though I believe the out of range is refering only to AllSkills). I added these members in the inspector and they are filled out.

What is my mistake?

class Skill {

//Active or Passive
var Active : boolean;

//SkillObject
var TheObject: GameObject;

var CooldownCurrent : float;
var CurrentStamina : int;
var StaminaCost : int;

}

var AllSkills : Skill[];


var SkillSlot : Skill[];


function Equip ( NewSkill : Skill, Slot : int ) {

	SkillSlot[Slot] = NewSkill;

	if (!SkillSlot[Slot].Active) {
		Instantiate (SkillSlot[Slot].TheObject,transform.position,transform.rotation);
	}



}

function Activate ( Slot : int ) {


	if (SkillSlot[Slot].CooldownCurrent == 0 && SkillSlot[Slot].StaminaCost < CurrentStamina ) {
		if (SkillSlot[Slot].Active) {
			Instantiate (SkillSlot[Slot].TheObject,transform.position,transform.rotation);
		}

	}

}


function Update () {

	if( Input.GetKeyDown(KeyCode.Alpha1)) {
		Activate(1);
	}
	if( Input.GetKeyDown(KeyCode.Alpha2)) {
		Activate(2);
	}

	
if(Input.GetKeyDown(KeyCode.T)) {
    	
   	Equip(AllSkills[0],0);
	}
}

AllSkills is never initialized in this code. It is a public variable, so the Inspector will create it for you at a size of 0. With a size of 0, any access you attempt will generate an index out of range. To fix it, you can either go the inspector and set the size of the array, or you can allocate space for teh array in code. If you do the latter, then you probably should make the array ‘private’.