#pragma strict
import System.Collections.Generic;
var loot : ItemClass[];
var Inventory : Inventory;
function Start () {
Inventory = GetComponent("Inventory") as Inventory;
}
function OnGUI()
{
GUILayout.BeginArea(Rect(0,0,500,050));
if(GUILayout.Button("Loot!"))
{
Giveloot();
}
GUILayout.EndArea();
}
function Giveloot(){
for(var x = 0; x < loot.length; x++){
Inventory.PlayerInventory.Add(loot[x]);
}
}
I have this script, but it keeps saying NullReferenceException: Object reference not set to an instance of an object. I dont know whats wrong. All anwsers are appresiated.
↧