IndexOutOfRangeExeption - Array index is out of range


Does anyone know how to fix the error, I just can’t figure it out and nobody else has encountered this error in combination with something like my script.

Here’s the error:
IndexOutOfRangeExeption: Array index is out of range.
ScanConsole.Update () (at Assets/Scripts/ScanConsole.js:19)

And here’s the script:

public var computer : GameObject;
public var textMesh : TextMesh;
public var cam : GameObject;
public var scanGui : GameObject;
public var index : int = 0;

public var inScanner : GameObject[] = new GameObject[1];
public var isExit : boolean = false;
public var isArrayDisplay : boolean = false;

function Start () {
	textMesh = GetComponent(TextMesh);

//textMesh.text = "";

function Update () {
	textMesh.text = "Selected: " +

function OnMouseDown () {


You should initialize the list in the Start of Awake function

function Start(){
inScanner = new GameObject[1];

I’m used to C#, so not sure if this is right

Making the index variable private worked, thanks a lot!