How do I pass a script via inspector reference?

I have a function on a Character Controller that’s called when it collides with any GameObject tagged ItemPickup, and calls the RequestPickUp method, passing the script, ItemPickup, from the colllided object.

   function RequestPickUp(itemScript : ItemPickup)
    {
    	if (canPickUp) {
    		itemScript.PickedUp();
    		inventoryObject.AddComponent(itemScript.item);
    	}
    }

Now, what I want to do is add the class itemScript.item is referencing to a holder GameObject (inventoryObject). I’d also like to be able to attach extensions from InventoryItem as well.

ItemPickup.js:

var item : InventoryItem;
    function PickedUp() {
    Destroy(parent);
    }

InventoryItem.js is so far an empty class extending from MonoBehaviour. It’s attached to the same object as ItemPickup.js and is linked via inspector reference.

class InventoryItem extends MonoBehaviour
{
}

But when compile time rolls around… I get:

‘No appropriate version of ‘UnityEngine.GameObject.AddComponent’ for the argument list ‘(InventoryItem)’ was found.’

Well, I am not home to test out a C# script, but, here is the Javascript version of that code. Hopefully it won’t be too hard to convert . . . .

//File name to access is OOP.js

var MyOOP : OOP ;

function Start ( )
{
   MyOOP = GetComponent ( OOP ) ;
   MyOOP.DoFunctionFromScript ( );
}

Pretty simple script, and I hope this solves your issue.
Good luck, and let me know if this is not what you are looking for . . . . .


Edit/Update:

//pickup

var item : InventoryItem;
function PickedUp() {
    Destroy(parent);
}

function Start ( )
{
    item = GetComponent ( ItemInventory )
}

If this is not working, please post the exact output from the console, please.