So ive got an inventory system, you press a button it opens a page shows ur items ect, but this inventory acts as a hotbar instead, you can open and close it.....problem is if you obtain a new item for example buying a sword, it doesn't show it in the inventory until you refresh it by closing it then reopening it....
so my question is, is there something i can add into my inventory script that refreshes is on a loop every so many seconds?
here is the script so u can see whats up.
wait(3) player = game.Players.LocalPlayer game.StarterGui:SetCoreGuiEnabled('Backpack',false) -- local Enabled = false function UpdateInventory() if Enabled == false then Enabled = true script.Parent.Frame.Visible = true script.Parent.HotBar.Visible = true script.Parent.Left.Visible = true script.Parent.Right.Visible = true script.Parent.MoveBar.Visible = true script.Parent.Frame.CanvasSize = UDim2.new(0,48*#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.Size = UDim2.new(0,40,0,40) Obj1.Position = UDim2.new(0,45*i-16,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 Enabled = false script.Parent.Frame.Visible = false script.Parent.HotBar.Visible = false script.Parent.Left.Visible = false script.Parent.Right.Visible = false script.Parent.MoveBar.Visible = false end end script.Parent.InvenButton.MouseButton1Down:connect(function() UpdateInventory() end) player.Backpack.Changed:connect(function() if Enabled == false then Enabled = true UpdateInventory() end if Enabled == true then Enabled = false UpdateInventory() end end)
wait(3) player = game.Players.LocalPlayer game.StarterGui:SetCoreGuiEnabled('Backpack',false) local TIMETOREFRESH = --How long until inv update local Enabled = false function UpdateInventory() if Enabled == false then Enabled = true script.Parent.Frame.Visible = true script.Parent.HotBar.Visible = true script.Parent.Left.Visible = true script.Parent.Right.Visible = true script.Parent.MoveBar.Visible = true script.Parent.Frame.CanvasSize = UDim2.new(0,48*#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.Size = UDim2.new(0,40,0,40) Obj1.Position = UDim2.new(0,45*i-16,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 Enabled = false script.Parent.Frame.Visible = false script.Parent.HotBar.Visible = false script.Parent.Left.Visible = false script.Parent.Right.Visible = false script.Parent.MoveBar.Visible = false end end script.Parent.InvenButton.MouseButton1Down:connect(function() UpdateInventory() end) while wait(TIMETOREFRESH) do UpdateInventory() end player.Backpack.Changed:connect(function() if Enabled == false then Enabled = true UpdateInventory() end if Enabled == true then Enabled = false UpdateInventory() end end)