My inventory system only updates when i click to open the inventory gui. When i close the inventory gui it clears all the data until i open it again (which updates new or removed items).
I want it to be more real-time updating rather than only when i open and close the inventory. I've tried wrapping the whole thing in a while loop, but because of the button:clone() it causes the inventory to flicker every time it grabs the list.
Is there a way for me to arrange my code and to check for items being added/removed from the list while the inventory gui stays open?
if input.KeyCode == Enum.KeyCode.E then
frame.Visible = not frame.Visible
if frame.Visible then
local inventory = game.ReplicatedStorage.RemoteFunctions.GetInventory:InvokeServer() -- get saved inventory
for i=1, #inventory do --loop entire inventory
local item = itemslist[tonumber(string.sub(inventory[i],1,3))]
local parentframe = frame["c"..item.class] -- item placed into correct class tab
local n = #parentframe:GetChildren()
local button = script.ImageButton:Clone()
button.Image = item.image
button.Parent = parentframe
button.code.Value = inventory[i]
button.slot.Value = i
local row = math.floor((n/6))
local col = n-row*6
button.Position = UDim2.new((0.15*col)+0.05,0,(0.02*row)+0.01,0)
button.EquippedLabel.Position = UDim2.new(0.5,0,0.5,0)
if string.sub(inventory[i],#inventory[i]) == "e" then
button.EquippedLabel.Visible = true
end
button.Name = item.name
local stats = item.stats
else -- clear everything in gui on closing inventory gui
for i=1,10 do
local c = frame["c"..i]:GetChildren()
for ii=1, #c do
c[ii]:Destroy()
end
end
end

1 comment
try adding a wait()