Removing child component removes ALL components with that name

Hello Everyone,

I am currently trying to make a crafting script, but have run into a bit of an error.
I am trying to get it that when I click a button that instantiates a new object (a campfire) , it will delete a child object (stick), but it wants to delete ALL inventory items named “stick” instead of just one. Would anyone know how I could fix this?
I’m new to crafting scripts, so any help would be appreaciated.

Here is where if I “push button it creates a campfire” part of the script:

var wood = 0;
var ItemType : Transform;
var ItemsInInv : Transform;
var HideItem : Transform;
 var playersInv : Inventory;

function OnGUI
{

if(GUI.Button(Rect(100,60,100,20), "campfire"))
            {
                 if (wood >= 1)
                 {
                clone = Instantiate(ItemType,transform.position, transform.rotation);
                stone -= 15;
                 
                for (var child : Transform in ItemsInInv.transform) 
                {
       				 if(child.name == "stick")
       			 	{
       			 	playersInv.RemoveItem(child);
           		
           		 //Destroy(child.gameObject);
           		
    			   }
    				}
    
                 }
    
    	}

}

Here is the function where I am calling for the item to be removed in another script:

function RemoveItem(Item:Transform)
{
	var newContents=new Array(Contents);
	var index=0;
	var shouldend=false;
	for(var i:Transform in newContents) //Loop through the Items in the Inventory:
	{
		if(i == Item) //When a match is found, remove the Item.
		{
			newContents.RemoveAt(index);
			shouldend=true;
			//No need to continue running through the loop since we found our item.
		}
		index++;
		
		if(shouldend) //Exit the loop
		{
			Contents=newContents.ToBuiltin(Transform);
			if (DebugMode)
			{
				Debug.Log(Item.name+" has been removed from inventroy");
			}
			if (playersInvDisplay != null)
			{
				playersInvDisplay.UpdateInventoryList();
			}
			return;
		}
	}
}

I know the script is a bit hectic, so I apologize in advance.

You don’t have a break; or a return; in the for-loop in the upper script so you indeed loop through all child objects that are called “stick”.

Add break; on the next line after playersInv.RemoveItem(child); inside the for loop so you’ll stop looking for sticks after you find one.