Targeting Ai For Enemy

i have void FindTarget() every frame;
it only works if there are some debug logs errors ;
i need to print target so it print error , then it dont go down , if not , it goes down ignoring every if() to switch

private void FindTarget()
{
if (Target == null)state = State.Roaming;

    Collider2D target = Physics2D.OverlapCircle(transform.position, TargetRange , WhatIsTargets);
    //if (target == null) return; with this it continues to switch loop infinite 
    if (Vector2.Distance(transform.position , target.transform.position) < TargetRange)
    {
        //if (target == null) return; with this it works fine but giving a lot of console problems when losing target 
        switch (target.gameObject.tag)
        {
            case "Player":
                TargetRange = ChasingTargetRange;
                Target = target.transform;
                TargetRB = target.attachedRigidbody;
                state = State.ChaseTarget;
                break;

            case "Noise":
                Target = target.transform;
                state = State.FollowNoise;
                break;
        }
    }

I don’t think the state is set back to roaming properly. Once a target is found Target is never set to Null again so the state never becomes Roaming again.

Something like this that assumes the roaming state might work:

void FindTarget() {
            Collider2D target = Physics2D.OverlapCircle(transform.position, TargetRange, WhatIsTargets);

            //Assumes target lost
            state = State.Roaming;
            Target = null;
            if (target == null) return;

            if (Vector2.Distance(transform.position, target.transform.position) < TargetRange)
            {
                //if (target == null) return; with this it works fine but giving a lot of console problems when losing target 
                switch (target.gameObject.tag)
                {
                    case "Player":
                        TargetRange = ChasingTargetRange;
                        Target = target.transform;
                        TargetRB = target.attachedRigidbody;
                        state = State.ChaseTarget;
                        return;
                    case "Noise":
                        Target = target.transform;
                        state = State.FollowNoise;
                        return;
                }
            }
        }