Array Index error

Greetings,
So I’m working on a 3D menu for my game by following a tutorial I found online. However, after further investigation the user was using Unity 2.6 and I’m on 3.1 This has messed things up in Scripting. I looked into this and found that I had to rename some of my variables, so I did, but I am now getting an error:

“IndexOutOfRangeException: Array index is out of range.”

I’m guessing this is because it’s trying to access a menu Item that doesn’t exist. My problem is, I don’t know how to get rid of this error. The error is coming from “menuItems[currentItem].OnSelected(true);” This is the very next line under " function Start(){ "
Here’s my Code:

var menuItems:menuItem[ ];
var currentItem:int = 0;
var keyDelay:float = 0.25;

function Start(){
menuItems[currentItem].OnSelected(true);

var lastMenuItem:int = currentItem;

while(true){
if(Input.GetAxisRaw(“Vertical”) > 0.9){
lastMenuItem = currentItem;
currentItem–;
if(currentItem < 0) currentItem = 0;

if(lastMenuItem != currentItem){
menuItems[currentItem].OnSelected(false);
menuItems[currentItem].OnSelected(true);
}
yield new WaitForSeconds(keyDelay);
}
else if(Input.GetAxisRaw(“Vertical”) < -0.9){
lastMenuItem = currentItem;
currentItem++;
if(currentItem >= menuItems.length) currentItem = menuItems.length - 1;

if(lastMenuItem != currentItem){
menuItems[currentItem].OnSelected(false);
menuItems[currentItem].OnSelected(true);
}
yield new WaitForSeconds(keyDelay);
}
yield;
}
}

Double-check and make sure that ‘currentItem’ is less than the length of ‘menuItems’ (and >= 0). If it’s not, it probably means you haven’t created the ‘menuItems’ array in the inspector, and/or have given ‘currentItem’ an invalid initial value.