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