Enemy freaking when trying to look at player

I have been trying to make the enemy look at the player when the players x position is larger than the enemys but when It trys to look at the player the collider freaks out and then it’s y position starts growing in the negitives really fast
This is the Code:

public class EnemyTexFlip : MonoBehaviour
{
public GameObject player;
public Collider2D enemyCollider;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
     if(player.transform.position.x > transform.position.x)
    {
       transform.localScale = new Vector3(-1f, 0f, 0f);
       
    }else if(player.transform.position.x < transform.position.x)
    {
      transform.localScale = new Vector3(1f, 0f, 0f);
      
    }
}

}

Never set Transform scales to zero.

Usually when working with sprites you just set the .flipX property to flip the sprite only, which is far less intrusive to everything else (such as colliders).

Thank you i cant believe I missed that