So ive got this inventory script. Its meant to be open all the time but is closeable with the click of a button. Problem is when u get rid of or get an item you need to close and reopen it to update and show the item in the inventory :/ which can get annoying. What im wondering is how would i make this "Auto Update" every few seconds or w/e so you dont have to keep closing and opening it every time u sell/ buy something or get a drop
heres my script
wait(.5) player = game.Players.LocalPlayer Close = game.Workspace.Close1 game.StarterGui:SetCoreGuiEnabled('Backpack',false) Close = game.Workspace.Close1 -- function UpdateInventory() if Close.Disabled == true then Close.Disabled = false elseif Close.Disabled == false then Close.Disabled = true end if Close.Disabled == false then script.Parent.Frame.Visible = true script.Parent.CenterCap.Visible = false script.Parent.Frame.CanvasSize = UDim2.new(0,46*#player.Backpack:children(),0,0) script.Parent.Frame:ClearAllChildren() for i,v in pairs(player.Backpack:GetChildren()) do Obj1 = Instance.new('ImageButton',script.Parent.Frame) Obj1.ZIndex = 10 Obj1.Size = UDim2.new(0,40,0,40) Obj1.Position = UDim2.new(0,45*i-40,0,7) Obj1.BackgroundTransparency = 0 Obj1.Image = v.TextureId Obj1.MouseButton1Down:connect(function() player.Character.Humanoid:UnequipTools() player.Character.Humanoid:EquipTool(v) end) end else script.Parent.Frame.Visible = false script.Parent.CenterCap.Visible = true wait(.3) end end script.Parent.InvenButton.MouseButton1Down:connect(function() UpdateInventory() end) player.Backpack.Changed:connect(function() if Close.Disabled == true then Close.Disabled = false UpdateInventory() end if Close.Disabled == false then Close.Disabled = true UpdateInventory() end end)
I didnt write the scripts i just edited it to fit what i needed, im actually a very big noob at Lua so sorry