Objects not following

So, firstly, here's my code:

var target : GameObject;
var range : float;
var speed : float;
function Update () 
    range = Vector3.Distance(target.transform.position, transform.position);
    if (range<50)

The objects are cubes and the target should be the player. The cubes are instantiated randomly, and it doesn't let me set the first person controller as the target in the prefab. I tried making the player a prefab and then using that as the target, but that didn't work. Any help?

Tag your player as "Player" then do something like this:

function Start()
  target = GameObject.FindWithTag("Player");

This will make the cube set its target as the GameObject tagged as "Player" as soon as it spawns.