Changing a dictionary value from another script

Hi, I’m tring to figure out how to set a dictionary value from another script. I have a GunClass and a InventoryClass. The GunClass handles all shooting mechanics, where the InventoryClass manages the state of the inventory. I keep my inventory items in dictionaries.

In the GunClass I check how many clips (int) I still have left in one of the dictionaries in my InventoryClass, like so:

if (Input.GetButtonDown("Reload"))
        {
            remainingClips = GameObject.FindGameObjectWithTag("InventoryController").GetComponent<InventoryClass>().playerAmmo[weaponType];
            if (remainingClips > 0)
            {
                Reload();
            }

This works fine. Reload() decreases remainingClips by 1. However, I also want to decrease the value in the dictionary itself by 1. I tried to do this by adding this line after Reload():

GameObject.FindGameObjectWithTag("Player Controller").GetComponent<FPSControl>().playerAmmo[weaponType] = remainingClips;

Edit: this is an old snippet: it is supposed to be:

GameObject.FindGameObjectWithTag("InventoryController").GetComponent<InventoryClass>().playerAmmo[weaponType] = remainingClips;

This however, doesn’t do anything. I’m unsure how to handle this problem. Any help would be greatly appreciated.

I fixed the problem using a workaround: Instead of changing the value directly, I changed a bool in the target script which adds or changes the dictionary value.