Would this Pseudocode work for Inventory?

Hello,
I’m trying to create an inventory system that has sections for emotes, skins, and characters and im not sure if the logic I’ve come up with would work.

--player buys item
insert item in INVENTORY table

--player leaves
save INVENTORY table to DATASTORE named playerInventory

-- player joins
get INVENTORY datastore

--Player clicks on inventory button
loop through playerInventory table
for i, item in playerInventory do
  if item,itemtype = emote then
      create new image button in emote section
-- use this code for other things like the skins and characthers
end
end

This would work, although I wouldn’t loop in the items table everytime the inventory is opened but rather once when the inventory is first loaded and everytime the player buys/sells/etc an item. This way it will update in the background rather than having to load up everytime the button is clicked (which would likely hurt performance if the player has hundreds of items to load)

1 Like