ArgumentOutOfRangeException: Argument is out of range? What wrong?

Well I’ve tried every thing I know (which isn’t much considering I’m a noobie) to fix this. Can some one help me fix the Error. Here is my code ItemClass:

public class ItemClass
{
public var name : String;
public var description : String;
public var icon : Texture2D;
public var itemType : ItemType;
enum ItemType{None, Weapon, Other}

}`

Inventory Script

import System.Collections.Generic;

var playerInventory : List. = new List.();
var scrollView : Vector2;
var Weapon : ItemClass;
var equipped : boolean = false;

function Update () {

}

function OnGUI () 
{

	GUILayout.BeginArea(Rect(Screen.width - 100,0,100,100));

	scrollView = GUILayout.BeginScrollView(scrollView, GUILayout.Width(100), GUILayout.Height(100));
	for(var x = 0; x < playerInventory.Count; x++)
	{

	GUILayout.BeginHorizontal();
		if(GUILayout.Button(playerInventory[x].icon))
		{
			playerInventory.RemoveAt(x);
			return;
		}
		GUILayout.Box(playerInventory[x].name);
		GUILayout.EndHorizontal();
		GUILayout.Box(playerInventory[x].description);
	}
	GUILayout.EndScrollView();
	GUILayout.EndArea();

	if(GUI.Button(Rect(Screen.width/2 - 25, Screen.height - 50,50,50), Weapon.icon)){


		}
	
	}`

AddItem Script:

import System.Collections.Generic;

var loot : ItemClass[];
var Inventory : Inventory;

function Start () {
Inventory = GetComponent("Inventory") as Inventory;
}

function OnGUI () {

GUILayout.BeginArea(Rect(0,0,60,60));
if(GUILayout.Button("loot"))
	{
		giveloot();
	}
GUILayout.EndArea();

}

function giveloot() {

for(var x = 0; x < loot.length; x++)
Inventory.playerInventory.Add(loot[x]);
}

These are the three scripts I am using to make an Inventory. Any help would be appreciated. Thanks in Advanced.

It depends if you know how big your array needs to be.

var loot = new ItemClass;

I have previously declared a 0 size array and expanded it when needed but this isn’t very efficient:

var loot = new ItemClass[0];

To resize by one:

System.Array.Resize.<int>(loot, loot.Length + 1);

You may have to replace int with your own Type, ItemClass. I’ve never tried using a Custom array type, so you may have to experiment a bit!