How to destroy my shot when it travels a certain distance from my player?

var shotSpeed : float = 20.0;
var hero : Transform;
var MaxDist : int = 10;

function FixedUpdate () 
{
	transform.Translate(0,0,shotSpeed * Time.deltaTime); 
	ShotDistance();
}

function ShotDistance()
{
	if (Vector3.Distance/*NEEDS TO BE A CAPITAL D IN DISTANCE!!!*/(hero.position, transform.position) > MaxDist)
	{
		Destroy(gameObject);
	}
}

Instead of using hero as the reference, use the spawn point for calculation,that way even if your hero moves anywhere, your bullet will be destroyed after your defined distance.

var spawnLocation : Vector3;
void Start()
{
    spawnLocation = transform.position;
}

function ShotDistance()
{
    if (Vector3.Distance(spawnLocation , transform.position) > MaxDist)
    {
       Destroy(gameObject);
    }
}

Here is the bullet script from Angry Bots :

#pragma strict

var speed : float = 10;
var lifeTime : float = 0.5;
var dist : float = 10000;

private var spawnTime : float = 0.0;
private var tr : Transform;

function OnEnable() 
{
	tr = transform;
	spawnTime = Time.time;
}

function Update() 
{
	tr.position += tr.forward * speed * Time.deltaTime;
	dist -= speed * Time.deltaTime;
	
	if (Time.time > spawnTime + lifeTime || dist < 0) 
	{
		//Spawner.Destroy( gameObject ); // you don't want to call the Spawner object
		Destroy( gameObject ); // you just want to destroy the bullet
	}
}

var shotSpeed : float = 20.0;
var hero : Transform;
var MaxDist : int = 10;

function Start(){
/*THIS FIXED IT. I DRAGGED MY PLAYER PREFAB FROM THE PROJECT FOLDER INTO HERO IN THE INSPECTOR BECAUSE I COULDN'T DRAG THE PLAYER PREFAB CLONE THAT I HAD DRAGGED INTO THE SCENE OR HIERARCHY INTO HERO IN THE INSPECTOR. THE PLAYER PREFAB IN THE PROJECT FOLDER DOESN'T MOVE FOR ANYBODY WONDERING WHY IT WOULD MATTER.*/
   hero = GameObject.FindWithTag("Player").transform;
}
 
function FixedUpdate () 
{
    transform.Translate(0,0,shotSpeed * Time.deltaTime); 
    ShotDistance();
}
 
function ShotDistance()
{
    if (Vector3.Distance/*NEEDS TO BE A CAPITAL D IN DISTANCE!!!*/(hero.position, transform.position) > MaxDist)
    {
       Destroy(gameObject);
    }
}