i want the enemy to stop at a certain distance from the player but he doesn't

how do i make the enemy stop moving at a certain distance?
this is the code i am using.

public float moveSpeed = 5f;
public float shootDistance = 2500000f;

Vector2 direction;

    private void Update()
    {
        direction = (player.position - transform.position).normalized;
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Rb.rotation = angle - 90f;

    }
    private void FixedUpdate()
    {
        if (Mathf.Abs(Vector2.Distance(player.position, transform.position)) > shootDistance-100f)
        {
            transform.position = new Vector2(transform.position.x + direction.x * moveSpeed * Time.deltaTime, transform.position.y + direction.y * moveSpeed * Time.deltaTime);
        }
        else
        {
            transform.position = new Vector2(-(transform.position.x + direction.x * moveSpeed * Time.deltaTime), -(transform.position.y + direction.y * moveSpeed * Time.deltaTime));
        }
    }

Well, you are saying, if the distance between the enemy and the player is > shootDistance minus 100…then move right, if not, move left. You have set shootDistance to 2500000 in the class, not sure what you set it to in the inspector. My first thought is that the distance between the 2 is never going to be greater than 2500000, the enemy will always perform the else and not the if.

As for your actual question, there are a bunch of ways, but for simplicity i recommend using colliders set as a trigger, or use raycasts. I will let you look those up and mess around with those.