Problem accessing NavMeshAgent

I am trying to change my enemy target when the enemy enter on trigger. Enemy has NavMeshAgent attached. In trigger I have code below. However it always displays on console “NavMeshAgent not found”. Could you please tell me what is the problem.

var nextTarget:Transform;

function OnTriggerEnter (other : Collider) {

if (other.GetComponent(NavMeshAgent) != null) {
	
	other.GetComponent(NavMeshAgent).destination = nextTarget.position;
}
else {
	Debug.Log("NavMeshAgent not found");
}

}

I’m not as skilled as i’d like to, but my little experience with navmesh says to use SetDestination() instead of setting the destination via destination variable.

That can only mean, that the object that enters the trigger doesn’t have NavMeshAgent attached.