Null Reference trying to get a value from another object

I’m messing around with the 2D side scroller tut, and decided to put a label on the main character.

I added this function in the script for the character, “PlatformerController.js”

function GetPosition () {
    return transform.position;}

And changed the Update function for the GUI Text object as

var player: PlatformerController;
function Update () {
   transform.position = player.GetPosition();
}

And I’m greeted with a Null Reference at that line.

NullReferenceException: Object reference not set to an instance of an object

I tried changing the update function to transform.position.set(0,0,0); , which did not return a Null Reference, so the problem seems to be that the GetPosition function is not behaving.

I’ve tried reading the cross referencing guide, but it didn’t help much.

http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Any help would be appreciated

You must define the function returning type:

function GetPosition (): Vector3 {
    return transform.position;
}

then you must select the GUIText object in the Hierarchy view and drag the character to the field Player in the Inspector - this saves in the variable player a reference to the script PlatformerController attached to the character.