Adding Distance in javascript

How can i add distance into a javascript? I'm trying to make an AI script and below is the part which involves distance

//Moving
var moveSpeed = 3.0;

//Transform Variables
var Target : Transform;
var bulletPrefab : Transform;
var dead : Transform;

//Attacking
var attackRange = 30.0;

function Attack ()
{
   var distance = Vector3.Distance(transform.position, Target.position); 

   if(distance > attackRange)
   {
       transform.LookAt(Target);
   }
}

Your script should work, except I think you might have meant to test for 'less than' instead of 'greater than'.

i.e.

if ( distance <= attackRange )
// attack the enemy, because you're within range

Try separating the variable and the calculation for the distance:

`
var distance : float;
distance = Vector3.Distance( transform.position, target.position );
//Also, be sure to name your variables in lower camelCase
`