When the enemy character shoots, the bullet won't go to the position of my player!

When the enemy character shoots, the bullet won’t go to the position of my player.

The Enemy Script:

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

public class Enemy : MonoBehaviour
{
    public float speed;
    public float stoppingDistance;
    public float retreatDistance;
    private float maxDistance;
    public int maxEnemyHealth;

    private float timeBTWShots;
    public float startTimeBTWShots;

    public Transform eFirePoint;
    private Transform player;
    public GameObject projectile; 
    public float projectileSpeed;
    private Vector2 target;

    private void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        target = new Vector2(player.position.x, player.position.y);

        maxDistance = stoppingDistance + retreatDistance * 2;
        timeBTWShots = startTimeBTWShots;
    }

    private void Update()
    {
        if(Vector2.Distance(transform.position, player.position) > stoppingDistance)
        {
            transform.position = Vector2.MoveTowards
            (transform.position, player.position, speed * Time.deltaTime);
        }
        if(Vector2.Distance(transform.position, player.position) < retreatDistance)
        {
            transform.position = Vector2.MoveTowards
            (transform.position, player.position, -speed * Time.deltaTime);
        }
        if(Vector2.Distance(transform.position, player.position) <= maxDistance
        || Vector2.Distance(transform.position, player.position) == maxDistance)
        {
            EnemyShoot();
        }
    }

    private void EnemyShoot()
    {
        if(timeBTWShots <= 0)
        {
            GameObject eBullet = Instantiate
            (projectile, eFirePoint.position, eFirePoint.rotation);

            projectile.transform.position = Vector2.MoveTowards
            (transform.position, target, projectileSpeed * Time.deltaTime);

            timeBTWShots = startTimeBTWShots;
        }
        else
        {
            timeBTWShots -= Time.deltaTime;
        }

        if(transform.position.x == target.x && transform.position.y == target.y)
        {
            Destroy(projectile);
        }
    }

    public void TakeDamage(int damage)
    {
        maxEnemyHealth -= damage;
        if(maxEnemyHealth <= 0)
        {
            Destroy(gameObject);
        }
    }
}

first of all, the problem could be that the player is a child of an object that affects it’s position. try to print “player.position” every frame (on update()) and check if it works.

second of all, your question is a bit unclear. is the bullet moving? is it moving to the wrong direction? what is the problem here exacly? (whats working and not againts what should work)

I’d recommend you have one class for Enemy and another for Projectiles
Then for the target I’d have target = player.transform.position rather than new Vector2.
Then you don’t need to have if(transform.position.x == target.x && transform.position.y == target.y) you can simply go by if (transform.position = target.position)
You also Instantiate a GameObject eBullet which I don’t understand where’s it coming from since you have a public GameObject projectile.
But I imagine the main issue is that you don’t have a method for the attack? I’m not too sure tbh but maybe something like this would help?

public void Attack()
    {
        Vector2 direction = player.position - eFirePoint.position;
        float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
        Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        eFirePoint.rotation = rotation;

        Instantiate(projectile, eFirePoint.position, eFirePoint.rotation);
    }

I hope it helps.