How to flip enemy 2D Sprite

In my game, I have the player castle in the center of the map and I have enemy spawn positions at the edge of the map. I am trying to find a way to make the enemy sprite face the direction they are moving in (left or right), I know about the “Flip” mechanic on the Sprite Renderer but all the tutorials I find are based on player input and none actually grab the direction of the gameobject.

@rickycolon9540 If you want this script to run on each enemy instance, you could do something like this

 public float speed;
 public Transform target;
 public SpriteRenderer spriteRenderer;

void Update ()
{
  //direction of the target depending of this object
  Vector2 direction = (target.position - transform.position).normalized; 
  //supposing that your object is initially looking right
 spriteRenderer.flipX = direction.x < 0;
 //if you are using another method of movement like rigidbody then do the same but with 
 //rigibody.velocity = direction * speed * Time.deltaTime
  transform.position += direction * speed * Time.deltaTime;
}