help with the turret

i have a script attached to a turret so when it is 10 ft away it notices you and starts firing but it just keeps looking at me no matter how far i am
here is te script

var target : Transform;

var range = 10.0;

function Awake()
{

if(!target)
	 {
		target = GameObject.FindWithTag("Player").transform;
	 }
}

function Update () 
{
	if(target && CanAttackTarget)
	{

		//transform.LookAt(LookAtTarget);
		var targetRotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up);;;;;;
		transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 1.5);
	}
}

function CanAttackTarget()
{
	if(Vector3.Distance(transform.position, target.position) > range)
	{
		
		return  false;
	}
	return true;
}

You’ve forgot the parenthesis in CanAttackTarget - it should be:

function Update () 
{
    if(target && CanAttackTarget())  // <= the function parenthesis were missing 
    ...

Without the parenthesis, CanAttackTarget is the function reference, which Unity interprets as always true in this case.