How can i destroy all the oldtemplates in a gui even if they have the same name

local function LoadItems()
	for i, item in pairs(DataFolder.OwnedItems:GetChildren()) do

		local oldTemplate = Container:FindFirstChild(item.Name) --does not work as intended 
		if oldTemplate then
			oldTemplate:Destroy()
		end

		local itemTemplate = Template:Clone()
		itemTemplate.Name = item.Name
		itemTemplate.Visible = true
		itemTemplate.Parent = Container

		itemTemplate.ImageColor3 = RarityColor1(item.Value)
		itemTemplate.Holder.ImageColor3 = RarityColor2(item.Value)
		
		

		
	end
end

DataFolder.OwnedItems.ChildAdded:Connect(LoadItems)

InventoryOpen.Title.MouseButton1Click:Connect(function()
	InventoryGUI.Visible = not InventoryGUI.Visible
	if StatsGUI.Visible == true then
		StatsGUI.Visible = false
	end
	LoadItems()
end)

i have multiple items with the same names so if i use this then it just deletes all of them with the same name

for _, v in ipairs(Container:GetChildren()) do
	if v.Name==item.Name then
		v:Destroy()
	end
end

when i do this only 1 item shows and the rest get deleted

And what is wrong? It deletes all the previous one and creates a new one. Or I misunderstood what you need?

there is many items that should show, its an inventory so the player will have multiple items with teh same name but theyre still different items.