My script for pick up items work is wrong! Help please

Script “Pick up”, which is located on the ship. Inside the ship is a laser that destroys asteroids. According to the plan, the laser should destroy, and the ship, running into the drop-down resources - should pick them up. However, only a laser picks them up, who should not participate in this.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Podbor : MonoBehaviour
{
    public AInv inventory;
   
    private void OnTriggerEnter2D(Collider2D stolk)
    {                        
        if (stolk.gameObject.tag == "Res")
        {            
            //Find existing item in inventory
            for (int i = 0; i < inventory.items.Length; i++)
            {        
                if (inventory.items<em>.Name == stolk.GetComponent<AItem>().Name && inventory.items_.stack != inventory.items*.maxStack){*_</em>

inventory.items*.stack++;*
Destroy( stolk.gameObject);
return;
}
}

//Find empty space for new item
for (int i = 0; i < inventory.items.Length; i++)
{
if (inventory.items*.Name == “empty”)*
{
inventory.items*.Name = stolk.GetComponent().Name;*
inventory.items*.stack = stolk.GetComponent().stack;*
inventory.items*.Image = stolk.GetComponent().Image;*
inventory.items*.maxStack = stolk.GetComponent().maxStack;*
inventory.items*.ID = stolk.GetComponent().ID;*

Destroy( stolk.gameObject);
break;
}
}
}
}
}

I think it is your if statement if (inventory.items*.Name== “empty”)*
maybe you have laser with “empty”
probably you have “empty” ammo?
Also this might be the reason, you have
if (inventory.items.Name == stolk.GetComponent().Name && inventory.items_.stack != inventory.items*.maxStack){
This has negation of stack and maxStack for existing item in inventory.
Next, you have, find empty space for new item. You have stack and maxStack in for loop.
You already have them negated and existing in your inventory. Now, you need to find empty space but you cannot because they will not allow ,maxStack. This may pick up with the laser. As an edit take out the maxStack on the second for loop or fix the if statement.
Edit this:
if (inventory.items.Name == stolk.GetComponent().Name && inventory.items.stack != inventory.items.maxStack){*_