Larger scale inventories

  1. I would like to achieve a lag safe inventory with a ton of buttons (Items).

  2. My issue is that I am very inexperienced in making inventories (This is my first attempt) and I know there is a better way that what I’m doing. I’m afraid that as the inventories get larger, lag will become an issue. In simple words, I want to know how the professionals (People who have done this more than once) achieve a lag free inventory.

  3. I’ve searched the Developer Hub I came up empty handed (although my search was very rushed).

local function inventory()
	for _, item in pairs(inv.menu["2"].list:GetChildren()) do
		for _, subitem in pairs(item:GetChildren()) do
			if subitem.Name ~= "list" and subitem.Name ~= "pad" then
				subitem.Activated:Connect(function()
					print("Clicked " .. subitem.Name)
				end)
			end
		end
	end
end
inventory()

Note: I used the format that they wanted me to use hopefully I did good! I also didn’t want to waste my own and your time write a more descriptive topic.:v:

1 Like

If I’m understanding this right, a potential issue I’m seeing here is that if this is the kind of inventory where things will be added or removed from, this system you have won’t work for items that are added after inventory() is called the first time. So you’d have to call it again, and with how it is now, you’d be repeating the subitem.Activated:Connect(function() for items that didn’t change at all. I’d be more worried about items double activating than lag at the moment. You can test your system for lag, though, by adding an extreme number of items to your inventory and see how it performs.

2 Likes

That’s a valid concern, I’ll look into restructuring it so the activation logic only applies to newly added items and I’ll test performance under heavy load under limited processing power. Thanks for pointing that out!

1 Like