(Newbie) Need help with collider detected.

I want to update my NPC target, if the target enter in the sphere collider of my NPC, It will attack the target.
If target death, I will attack the next target in range. But some how my NPC wont attack the next target in range until the death target was destroyed. I add a front game ob to check which is death or not but look like the target of my NPC won’t update until the death target destroy !

GameObject CurrentTarget;
void OnTriggerEnter (Collider target){
        if (target.gameObject.tag == ChaseEnemyTag && target.gameObject.transform.GetChild (0).name == "front") {
          
            CurrentTarget = target.gameObject;
        }
    }

I also tried

GameObject CurrentTarget;
void OnTriggerEnter (Collider target){
        if (target.gameObject.tag == ChaseEnemyTag && target.gameObject.transform.GetChild (0).name == "front") {
          
            CurrentTarget = target.gameObject;
        }
        else{
               CurrentTarget = null;
        }
    }

How to make the CurrentTarget update if the last is death ? Thank you

You can give target a public flag like isDead and NPC can access target script and check if target is dead. Then he can clear his CurrentTarget variable and seek new target.

I gave a death enemies a “finish” tag when their healthbar < 0 but somehow the collider doesn’t update it, the collider alway wait for the gameobject of the enemies destroy before it seek for the new target !