private void KilledBy(GameObject source) { InventoryNPC myInv = GetComponent <InventoryNPC>(); if (WeaponSlot.transform.childCount > 0) { InvItem weapon = WeaponSlot.transform.GetChild(0).GetComponent <InvItem>(); if (weapon) { myInv.GiveItem(weapon); } } if (ArmorSlot.transform.childCount > 0) { InvItem armor = ArmorSlot.transform.GetChild(0).GetComponent <InvItem>(); if (armor) { myInv.GiveItem(armor); } } LootCrate.SpawnLootcrateOn(transform); Destroy(gameObject); }