Bullet Prefab spawning in multiple random positions and rarely the correct one (Unity 3D)

If I don’t make the Bullet Spawn position a child of my gun it spawns bullets in the correct position but when i make it a child of my gun it spawns in random positions.

Here’s the bullet script:

public class GunScript : MonoBehaviour
{
    public GameObject BulletPrefab;
    public Transform BulletSpawn;

    int Firing;

    // Start is called before the first frame update
    void Start()
    {
        //BulletSpawn = GameObject.FindWithTag("BulletSpawn").GetComponent<Transform>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButton("Fire1") && Firing == 0)
        {
            //GameObject bullet = Instantiate(BulletPrefab, BulletSpawn.position, Quaternion.identity) as GameObject;
            //bullet.GetComponent<Rigidbody>().AddForce(transform.forward * 100);
            StartCoroutine(Fire());
        }
    }

    IEnumerator Fire()
    {
        Firing = 1;
        GameObject bullet = Instantiate(BulletPrefab, BulletSpawn.position, BulletSpawn.rotation);
        //bullet.transform.position = BulletSpawn.position;
        yield return new WaitForSeconds(0.15f);
        Firing = 0;
    }

Dear,
I dont see where you assign bullet as a child. Maybe you should send 2 versions of code.
One that is working and one that is not working.

I think the problem is how you assign the parent to the child.
Do you use method parent or set parent? and when you change child coordinates, after assigning parent or before.

What I would suggest is to change your bullet coordinates first to your gun coordinates. And then just change parent with parent method.

But more I would be able to say after seeing the code.