I am making a script which will recieve an event for when the inventory gets updated, and adds items to the inventory gui.
When the inventory updates, the client recieves everything and the items are inside the inventory frame in the explorer, however, it doesnt actually render on the screen until I click the inventory frame in the explorer. It’s really weird.
That’s not the issue. The script updates everything perfectly, but the gui doesn’t render on the screen until I select it in the explorer. (As you can see in the GIF, the “wood” frame was in there all along, but it didn’t update on the screen for some reason.
sendInventory.OnClientEvent:Connect(function(Inventory)
local ItemsInInventory = inventoryHolder.ItemContainer:GetChildren()
local ItemsInHotbar = hotbarHolder.ItemContainer:GetChildren()
print("Client recieved")
for slot, Item in ipairs(Inventory) do
if not inventoryHolder.ItemContainer:FindFirstChild(Item.name) then
local itemFrame = itemTemplate:Clone()
itemFrame.Amount.Text = Item.amount
itemFrame.LayoutOrder = slot
itemFrame.Name = Item.name
itemFrame.Parent = inventoryHolder.ItemContainer
else
if Item.amount > 0 then
local itemFrame = inventoryHolder.ItemContainer:FindFirstChild(Item.name)
itemFrame.Amount.Text = Item.amount
else
local itemFrame = inventoryHolder.ItemContainer:FindFirstChild(Item.name)
itemFrame:Destroy()
end
end
end
for _, v in pairs(ItemsInInventory) do
if v:IsA("Frame") then
local found
for _, k in pairs(Inventory) do
if k.name == v.Name then
found = true
break
end
end
if not found then
v:Destroy()
end
end
end
end)
As I said, it becomes visible one you select the inventory in the explorer, and I dont think the visible property can just change itself from a frame being selected in the explorer. Everything is set to visible.