Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
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
0
whats the position of the cloned object Puppynniko 1059 — 2y
0
They're using a UIGridLayout, so their positions are set. WhenI click on them in the explorer I can see their outlines. AbettrWesley 6 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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
Ad

Answer this question