Raycast causes all enemies to attack

So for my game, I have tried a few different ways of detecting my player to get the enemies to stop and attack. However, I want only the current one that detects the player to stop and proceed to attack (they are all prefabs of the same model).

I’ve tried using a raycast to project a ray both forwards and backwards from the enemy for detection. This seems to work, but all of the enemies in the scene stop and proceed to do the attack animation (and they get stuck doing this and won’t return to their patrol state once the player isn’t detected anymore).

I believe one problem with it getting stuck is destroying the enemy before the player leaves the detection zone. Outside of that I am stumped as to how I should go about fixing this is.

Enemy Attack:

 void Update()
    {
        #region Commented Out
        //Debug.Log(playerSeen);

        //Vector3 relativePos = target.position - transform.position;
        //Quaternion rotation = Quaternion.LookRotation(relativePos);
        //rotation.y = 0;
        //rotation.x = 0;
        //rotation.z = 0;

        //transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * fireSpeed);
        #endregion

        ////Grabs the forward vector of this game object
        Vector3 fwd = this.transform.TransformDirection(Vector3.forward);
        Debug.DrawRay(transform.position + (transform.up * -0.2f), -fwd * 3, Color.green);
        Debug.DrawRay(transform.position + (transform.up * -0.2f), fwd * 3, Color.red);

        //Raycast to detect player
        if (Physics.Raycast(transform.position + (transform.up * -0.2f), fwd * 3, out hit, 3) && this.hit.collider.gameObject == playerLoc ||
            Physics.Raycast(transform.position + (transform.up * -0.2f), -fwd * 3, out hit, 3) && this.hit.collider.gameObject == playerLoc)
        {
            playerSeen = true;
            //Debug.Log("HIT");
            Debug.Log("This should be true: " + playerSeen);
        }
        else
        {
            playerSeen = false;
            Debug.Log("This should be false: " + playerSeen);
        }

        Debug.Log(playerSeen);

        //Get distance between player and the enemy
        distance = Vector3.Distance(transform.position, target.position);

        if (distance < range && Time.time > lastShotTime + (3.0f / fireRate) && playerSeen)
        {
                lastShotTime = Time.time;
                LaunchProjectile();
        }
    }

Enemy Movement:

void Update()
    {
        //Moves if the player isn't seen and stops/attacks if the player is seen
        if (!playerSeen)
        {
            //Start Movement
            StartCoroutine(Movement());
            
            //Animation
            anim.SetBool("Patrolling", true);
        }
        else
        {
            //Animation
            anim.SetBool("Patrolling", false);
            
            //Stop Movement
            StopCoroutine(Movement());

            //Handles flipping enemy to face the target while playerSeen
            if (enemyAttack.target.position.x < this.transform.position.x)
            {
                this.transform.rotation = lookLeft;
            }
            else if (enemyAttack.target.position.x > this.transform.position.x)
            {
                this.transform.rotation = lookRight;
            }
        }
    }

 IEnumerator Movement()
    {
        //Check for position and switch direction flag if condition is met
        if (transform.position == targetLoc.position)
        {
            switchDirection = true;
        }

        if (transform.position == startLoc.position)
        {
            switchDirection = false;
        }

        //Handles movement between two points
        if (switchDirection)
        {
            //Flip Model to face other direction
            transform.rotation = lookLeft;

            //Move the model
            transform.position = Vector3.MoveTowards(transform.position, startLoc.position, moveSpeed);
        }
        else if (!switchDirection)
        {
            //Flip Model to face other direction
            transform.rotation = lookRight;

            //Move the model
            transform.position = Vector3.MoveTowards(transform.position, targetLoc.position, moveSpeed);
        }

        //Tells the compiler that there is no return...error handling
        yield return null;
    }

Remove the static modifier.

Also, you could be using: Time.deltaTime to make it framerate independent.