I am building an inventory system. In my LocalScript, I am able to create an ImageButton for each item that I want to populate in the GUI.
-- This is a ScrollingFrame
local item_list_frame = inventory_frame.ItemListFrame
-- This is a UIGridLayout
local ITEM_GRID = item_list_frame.ITEM_GRID
-- Populate the inventory GUI using data from the server side.
local function PopulateInventory()
-- Reset the inventory GUI
ITEM_GRID:ClearAllChildren()
-- Get the inventory metadata from the server.
local inventory_data = PopulateInventoryGui:InvokeServer()
-- Add each item to the UIGridLayout
for index, item in ipairs(inventory_data) do
local item_thumbnail = Instance.new("ImageButton")
item_thumbnail.BackgroundTransparency = 1
item_thumbnail.Image = ("rbxassetid://"..item.display_image_asset_id)
item_thumbnail.Name = item.display_name
item_thumbnail.Parent = ITEM_GRID
end
end
The code seems to work as expected, because when I print the children of the UIGridLayout, it shows that all the ImageButtons are populated.
print(ITEM_GRID:GetChildren())
The problem is, all these ImageButtons are invisible when they are a child of the ITEM_GRID
. If I use the Explorer and drag them into the ItemListFrame, they become visible.
What am I doing wrong here? Is there something I need to change about my GUI layout? How can I get the UIGridLayout to show up inside of the ScrollingFrame?