How do I pass an object to another script?

It’s been a while (a few years, actually) since I picked up Unity and I’m trying to get back into it. From what I’ve seen so far, #pragma strict appears to be all the rage lately. However, it apparently doesn’t use dynamic typing, which I think is the root of my issue. I’m simply trying to pass an instance of a class from one script to another. However, I’m getting this error:

‘name’ is not a member of ‘Object’

When I attempt to run this code:

In Item.js:

function OnTriggerEnter(other : Collider) {
	if(other.gameObject.CompareTag("Player")) {
		var weapon = new PlayerItem("Test Weapon Name");
		other.SendMessage("AddItemToInventory", weapon);
	}
}

In PlayerInventory.js:

class PlayerItem {
	var name : String;
	function PlayerItem(g_name : String) {
		name = g_name;
	}
}

function AddItemToInventory(itemProperties) {
	Debug.Log(itemProperties.name);
}

Where did I go wrong? UnityScript today isn’t the UnityScript I remember. Heh.

You should define the parameter type of itemProperties:

function AddItemToInventory(itemProperties: PlayerItem){

SendMessage passes an object type (variant) to the called function, thus it can be anything - you must specify which’s the actual parameter type.