Enemy Sprite not switching based on movement angle

Hello, I have been having some issues getting my enemy sprite to switch based on the angle it is facing or the target. Although, it seems to be correctly detecting wether it is moving up down left or right. The sprite does not seem to be changing, the only thing I could think of that could be causing it is if something one is over riding another but I have tried a lot of combinations with no luck.

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

public class zombieBehavior : MonoBehaviour
{
    public GameObject player;
    private GameObject attack;
    private Rigidbody2D rb;
    public float attackSpeed = 1;
    [SerializeField] private float speed = 1;
    [SerializeField] private float rSpeed = 1;
    [SerializeField] private float proximityOffset;
    [SerializeField] private float range;
    [SerializeField] private float rotationModifier = 200f;
    private float distance;
    public float health = 100f;
    public bool isDead = false;

    private bool isAttacking = false;
    private SpriteRenderer[] spriteRenderers;

    [SerializeField] private Sprite upSprite;
    [SerializeField] private Sprite downSprite;
    [SerializeField] private Sprite lrSprite;



    private bool isMovingY = false;
    private bool isMovingX = false;

    UnityEngine.AI.NavMeshAgent agent;




    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        spriteRenderers = GetComponentsInChildren<SpriteRenderer>();
        player = GameObject.FindWithTag("Player");

        attack = GameObject.Find("meleeAttack");

        agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
        agent.updateRotation = false;
        agent.updateUpAxis = false;


        if (spriteRenderers == null)
        {
            Debug.LogError("SpriteRenderer component not found. Please attach a SpriteRenderer to the GameObject.");
        }
    }

    void FixedUpdate()
    {
        distance = Vector2.Distance(transform.position, player.transform.position);
        Vector2 direction = (player.transform.position - transform.position).normalized;

        // Move towards the player
        //transform.position = Vector2.MoveTowards(transform.position, player.transform.position, speed * Time.deltaTime);

        // Rotate to face the player
        Vector3 vectorToTarget = player.transform.position - transform.position;
        float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg - rotationModifier;
        Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward);
        //transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rSpeed);

        Vector3 localScale = transform.localScale;
        isMovingX = Mathf.Abs(direction.x) > Mathf.Abs(direction.y);
        isMovingY = !isMovingX;

        if (isMovingX)
        {
        // Flip on X-Axis
            if (player.transform.position.x < transform.position.x)
            {
                localScale.x = -Mathf.Abs(localScale.x);
                Debug.Log("Moving left");
            }
            else
            {
                localScale.x = Mathf.Abs(localScale.x);
                Debug.Log("Moving right");
            }

            foreach (var spriteRenderer in spriteRenderers)
            {
                spriteRenderer.sprite = lrSprite;
            }
        }
        else if (isMovingY)
        {
            // Switch sprite based on Y-Axis
            if (player.transform.position.y < transform.position.y)
            {
                foreach (var spriteRenderer in spriteRenderers)
                {
                    spriteRenderer.sprite = downSprite;
                }
                Debug.Log("Moving down");
            }
            else
            {
                foreach (var spriteRenderer in spriteRenderers)
                {
                    spriteRenderer.sprite = upSprite;
                }
                Debug.Log("Moving up");
            }
        }


        transform.localScale = localScale;


        //agent.SetDestination(player.transform.position);


        if (distance > proximityOffset){
            agent.SetDestination(player.transform.position);
        }else if(distance <= proximityOffset){
            StartCoroutine(Attack());
        }

        // Check if health is zero or less
        if (health <= 0)
        {
            Destroy(gameObject);
        }


    }

    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("bullet"))
        {
            health -= 25;
            StartCoroutine(FlashRed()); // Start the FlashRed coroutine
        }

        if (collision.gameObject.CompareTag("Zombie"))
        {
            Debug.Log("Collided with Other Zombie");
        }




    }

    private IEnumerator FlashRed()
    {
        if (spriteRenderers != null)
        {
            foreach (var spriteRenderer in spriteRenderers)
            {
                spriteRenderer.color = Color.red;  // Change color to red
            }
            yield return new WaitForSeconds(0.5f);  // Wait for 0.5 seconds
            foreach (var spriteRenderer in spriteRenderers)
            {
                spriteRenderer.color = Color.white;  // Change color back to white
            }
        }
    }




    private IEnumerator Attack()
    {
        isAttacking = true;
        attack.SetActive(true);
        yield return new WaitForSeconds(2.5f);
        attack.SetActive(false);
        yield return new WaitForSeconds(attackSpeed);
        isAttacking = false;

    }
}

You say issues "getting my enemy sprite to switch based on the angle it is facing or target". What do you mean by switching? And you say the "sprite does not seem to be changing" but what do you mean by changing? Are you trying to get it to rotate towards the player properly? Or when you say "Switch" do you mean change the sprite via animation?