I had to check if the weaponInfo was null before trying to set the weaponToSpawn otherwise the error wouldnt clear.
private void ChangeActiveWeapon()
{
Transform childTransform = transform.GetChild(activeSlotIndexNum);
InventorySlot inventorySlot = childTransform.GetComponentInChildren();
WeaponInfo weaponInfo = inventorySlot.GetWeaponInfo();
if(weaponInfo == null)
{
Debug.Log("WeaponInfo is null");
ActiveWeapon.Instance.WeaponNull();
return;
}
GameObject weaponToSpawn = weaponInfo.weaponPrefab;