My function can not update

I tried to find the answer for 2 days but I can’t

Question: I want when the “Player” comes near the Turret, I will have a report “in” and far away is “out”
In this script, when I come near the Turret, report “in” appears, and far away is “out” but when I go near again, I can’t have report “in”. Can someone please help me here?

Thanks in advance, Regards

Can someone please help me here?

    var target: Transform;
var range = 10.0;

function Awake()
{
	target = GameObject.FindWithTag("Player").transform;
}

function Update()
{
CanAttackTarget();
if (target && CanAttackTarget())
{
var targetRotation = Quaternion.LookRotation(transform.position - target.position,Vector3.up);
transform.rotation=Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime* 2);
}
}

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

Uncheck “Collapse” button in your Console.

When Collapse is enabled, identical messages will only be shown once.

Chances are you’re collapsing identical messages, meaning that if you already had a “out” or “in” message, no further messages are shown. Uncheck Collapse to see if you don’t get spammed with a ton of “in”/“out” messages. If you ever had only one instance of that “in”/“out” message, then you probably have it checked.

Change your function to:

function CanAttackTarget:boolean()
{
    if(Vector3.Distance(transform.position, target.position)>range)
    {
        print("out"); 
        return false;
    }
    else{
        print("in");
        return true;
    }
}