Hello,
I’ve got an issue. I’m building an Inventory. Once the player has picked up an item the item is added to the UI inventory wrapper. The buttons are prefabs. The issue is once an inventory item is clicked all of the buttons are called on click.

For instance if there is more than one 9mm pistol in the players inventory and the player clicks on one of the 9mm Pistols to equip it then all of the other 9mm pistols within the inventory is called as if the player clicked on all the buttons at once.

Here is the equip script.

public void EquipItem()
    {
        if(this.name.Contains("(WEP)"))
        {
            foreach(Weapons i in gm.GetComponent<inventoryMaster>().playerWeapons)
            {
                if(i.WeaponName == this.name)
                {
                    if(i.handed == 1)
                    {
                        if(gm.GetComponent<inventoryMaster>().currentWeapon != null)
                        {
                            Destroy(gm.GetComponent<inventoryMaster>().currentWeapon);
                            equipedIcon.SetActive(false);
                            return;
                        }
                        else
                        {
                            GameObject equipedWep = Instantiate(i.weaponObj, oneHandedPoint.transform.position, oneHandedPoint.transform.rotation) as GameObject;
                            equipedWep.transform.SetParent(oneHandedPoint.transform);
                            equipedWep.transform.localScale = new Vector3(0.0007f, 0.0007f, 0.0007f);
                            gm.GetComponent<inventoryMaster>().currentWeapon = equipedWep;
                            equipedIcon.SetActive(true);
                        }
                    }
                }
            }
        }
    }

Thank you for any help on this.

At the end of if(i.WeaponName == this.name) (before closing the area of code with } ) put a break; line.
BTW, I don’t think your code is the best way to achieve what you are trying to do.