making 2d teammate ai shoot enemy and follow player and when enemy is in range he going to kill them

hello friends please help me to complete my ai script . this script is almost complete but its problem is when he find enemy tag and kill enemy he is not try to find next enemy please help i am not professional but you guys are here is my srcript

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Aishooting02 : MonoBehaviour
{

public float speed;
public float lineofsite;
public float shootingrange;
public GameObject bullet;
public GameObject bulletparent;
private Transform player; //Player is Enemy or target to follow samaz m aya
                          // Start is called before the first frame update

public GameObject Muzzelflash;
[Range(0, 5)]
public int Frametoflash;
bool _isflashing = false;
void Start()
{
    Muzzelflash.SetActive(false);
    player = GameObject.FindGameObjectWithTag("Enemy").transform;
   
   

}

void Update()
{
    float distancefromplayer = Vector2.Distance(player.position, transform.position);
    if (distancefromplayer < lineofsite && distancefromplayer > shootingrange)
    {
        transform.position = Vector2.MoveTowards(this.transform.position, player.position, speed * Time.deltaTime);
    }
    else if (distancefromplayer <= shootingrange)
    {
        Instantiate(bullet, bulletparent.transform.position, Quaternion.identity);

        if (!_isflashing)
        {
            StartCoroutine(doflash());
        }
       
    }
    
   
}

IEnumerator doflash()
{
    Muzzelflash.SetActive(true);
    var framflased = 0;
    _isflashing = true;

    while (framflased <= Frametoflash)
    {
        framflased++;
        yield return null;
    }
    Muzzelflash.SetActive(false);
    _isflashing = false;

}

private void OnDrawGizmosSelected()
{
    Gizmos.color = Color.green;
    Gizmos.DrawWireSphere(transform.position, lineofsite);
    Gizmos.DrawWireSphere(transform.position, shootingrange);
}

}

Hi,
You could check at the start of the Update function if player is dead and if yes then Find another, if you destroy game objects after bullet hit, you can try do something like that:

if(player == null)  // or another check if player was killed
       player = GameObject.FindGameObjectWithTag("Enemy").transform;

Of course now there is a problem, with no enemies code will throw exception so you will have to take it into an account.