public void AddItemToInvetory() { if (playerItems == null) { this.Awake(); } var slotToAddTo = playerItems.gameObject.GetComponentsInChildren <MyInventorySlot>()[Armour.GetSlotIndex(item.ArmourSlot)]; ArmourPiece itemBackup = slotToAddTo.GetArmourPiece(); if (slotToAddTo != null) { slotToAddTo.AddItem(this.item); } else { Debug.Log("ERROR!"); } if (itemBackup != null) { this.item = itemBackup; UpdateSlot(); } else { Object.Destroy(this.gameObject); } }