When I switch weapons the UI ammo count does not change to match the current weapon

At the moment, When I switch weapons, the UI ammo count does not change to match the current weapon I am holding, the switched weapon works and fires as expected but the UI still displays the amount for the previous weapon.

This is the from the gunscript, where the amo is displayed

    private void Update()
    {
        MyInput();

        //Set ammo display, if it exists :D

        // need to Identify the right weapon before displaying the ammo, to stop showing ammo for wrong weapon.
        if (ammunitionDisplay != null)
            ammunitionDisplay.SetText(bulletsLeft / bulletsPerTap + " / " + magazineSize / bulletsPerTap);
    }

I think the code needs to go where the comment is, to select the right ammo count before displaying it
Any help would be awesome, and get a mention in the game credits.

Also If anyone has a better way of doing this I would love to hear it.

This is the weapon switch code if anyone needs to see it.

public class WeaponsSwitching : MonoBehaviour
{
    public int selectedWeapon = 0;
   // Start is called before the first frame update
    void Start()
    {
        SelectWeapon();
    }

    // Update is called once per frame
    void Update()
    {
        int preveousSelectedWeapon = selectedWeapon;

        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            if (selectedWeapon >= transform.childCount - 1)
                selectedWeapon = 0;
                else
                selectedWeapon++;
         }
        if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            if (selectedWeapon <= 0)
                selectedWeapon = transform.childCount - 1;
            else
                selectedWeapon--;

        }
        if (preveousSelectedWeapon != selectedWeapon)
          {
            SelectWeapon();
        }
    }

    void SelectWeapon()
      {
        int i = 0;
        foreach (Transform weapon in transform)
        {
            if (i == selectedWeapon)
                weapon.gameObject.SetActive(true);
            else
                weapon.gameObject.SetActive(false);
           i++;
        }
   }

}

Make sure that each of your guns have the script that updates the UI with ammo. Maybe you only have that script attached to the first gun?