Custom Inventories?

I’m working on a Custom Inventory / Backpack for the Player. However, I’ve ran into this issue -
Note the while true is just there for my own reference

I work this by having an ObjectValue within the ImageLabel that sets the Value to the corresponding item in the Players inventory. However - My intention is that the script checks to see if the Item is the same as the ObjVal and if so - It already exists so no need to clone it. However, this occurs:

Note, there is only 1 item in the Players Inventory to even begin with.

Update = function()		
	for i, item in pairs (Inventory["Tools"]:GetDescendants()) do
		if item:IsA("NumberValue") then
			for _,p in pairs (UI:GetDescendants()) do
				if p:IsA("ObjectValue") then
					if p.Value == item then break end
					local _Icon = script["Box"]:Clone()
					_Icon:WaitForChild("Match").Value = item
					_Icon.Parent = UI["Frame"]["Storage"]["ScrollingFrame"]
				end
			end
		end
	end
end

while true do wait(2.5)
	Update()
end
2 Likes

are you setting the objectvalue’s value in the image label? From the code you gave, you just clone the imagelabel but don’t actually set the objectvalue.

1 Like

I think I ran into a similar issue. Are the tools being stored in the player‘s backpack or somewhere else?

1 Like

I am, the ObjectValue is within the Image.
The Object Value is ‘Match’.

They’re not tools per-say, they’re NumberValues. But they’re stored within a Custom Folder titled ‘Inventory’ inside the Player.

Even after re-coding and editing it I get the following:
The issue persists, however, it still prints “found”.
@RaedXD @FancyTaik123

isExisting = function(Item)
	for _,i in pairs (UI["Frame"]:GetDescendants()) do
		if i:IsA("ImageButton") then
			if i.Match.Value == Item then
				return true
			else
				return false
			end
		end
	end
end

Update = function()
	for _,Item in pairs (Inventory["Tools"]:GetDescendants()) do
		if Item:IsA("NumberValue") then
			if not isExisting(Item) then
				local _Icon = script["Box"]:Clone()
				_Icon["Match"].Value = Item
				_Icon.Parent = UI["Frame"]["Storage"]["ScrollingFrame"]
			else
				print("Found!")
			end
		end
	end
end

while true do wait(2.5)
	Update()
end

I think this was the issue! I moved the placement of return false and now it’s stopped the MultiCloning!

3 Likes