Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why can't I see a cloned instance on the explorer tab?

I'm trying to see if I can build an inventory system from scratch, and I'm starting with turning the Starterpack into a table, then cloning an image for every item in that table, and putting it in a scrolling frame. The only problem is, I can't see the images under the scrolling frame in the explorer tab, and when I made it print the scrolling frame's children, it returned 'nil' in the output. But for some reason when I change the scrolling frame in the script from being defined as a variable to the correct path from the script instead, I can see the images under the scrolling frame, but the images themselves are completely invisible in game and I have absolutely no idea why. Can anyone help me with this?
local icon = script.Parent.ItemIcon
local invF = script.Parent.InvFrame
local invScroll = invF.InvScroll
local hotbar = script.Parent.Hotbar
local invTable = game.StarterPack:GetChildren()
print(invScroll:FindFirstChildWhichIsA("ImageButton"))

for i, v in pairs(invTable) do
	local InvIcon = icon:Clone()
	InvIcon.Parent = invScroll
	InvIcon.Name = "Item"
	InvIcon.IconLabel.Text = v.Name
end

2 comments

0

whats the position of the cloned object

0

They're using a UIGridLayout, so their positions are set. WhenI click on them in the explorer I can see their outlines.

1 answer

When you run the game, you can’t get the StarterPack of the game. Instead, get the Backpack of the LocalPlayer.

local icon = script.Parent.ItemIcon
local invF = script.Parent.InvFrame
local invScroll = invF.InvScroll
local hotbar = script.Parent.Hotbar
local invTable = game.Players.LocalPlayer:WaitForChild("Backpack"):GetChildren()
print(invScroll:FindFirstChildWhichIsA("ImageButton"))

for i, v in pairs(invTable) do
    local InvIcon = icon:Clone()
    InvIcon.Parent = invScroll
    InvIcon.Name = "Item"
    InvIcon.IconLabel.Text = v.Name
end

This discussion is preserved as it was. New answers, comments, and votes are closed.