Setting other script's variables

Hi! I have a problem with assigning a newly created instance’s script’s variables.
Here’s what i’m trying to do:
The player collides with trigger object. The trigger object is removed and the function addPiece is called like so:

function OnTriggerEnter (other:Collider) {
Destroy(other.gameObject); 
addPiece(); 
}

This is what my addPiece looks like

function addPiece () {
var newPiece : GameObject = Instantiate(part, transform.position+Vector3(0, 1, 0), Quaternion.identity);  
newPiece.name = "Piece";
newPiece.GetComponent.<SmoothFollow>().target = lastPiece.transform;
lastPiece = newPiece;}

part is prefab with a sphere that has SmoothFollow attached to it. I’m trying to set the target variable of SmoothFollow attached to the created newPiece to lastPiece’s (a GameObject) transform. I’ve been googling like crazy, seatching this forum and reading the scripting reference and various tutorials to no luck. The instantiation works (i see sphere falling from the sky), but it does not set a target to follow. Instead, i get:

NullReferenceException
Mato.addPiece () (at Assets/Scripts/Mato.js:34)
Mato.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/Mato.js:27)

So how do I make this work?

Try this, in your OnTriggerEnter function, make sure you add a game tag to the object and put it in an if statement. For instance,

function OnTriggerEnter (hit:Collider)
if(hit.gameObject =="Piece")
{
Destory(gameObject);
addPiece();
}

I think you misunderstood my problem. AddPiece is a function!

Hitting the trigger works fine, the object is removed, the function AddPiece gets called etc…

Inside the AddPiece function i instantiate a new GameObject.

I set it’s name to “piece”. All is well until i try to do this :

newPiece.GetComponent.().target = lastPiece.transform;

So i’m trying to set the SmoothFollow’s target to LastPiece. I’ve tried all kinds of variations but all i get is more grey hair.

All i get is errors all day and night. I’m trying to build this type of game:

http://www.vimeo.com/21549895

(and before you say “just follow the tutorial”… I have! ).

I’m sure accessing other instance’s components is something everyone does all the time while making games. So how is it done properly???