Frames aren't working

Hey, I’m trying to spawn in a frame in player gui. The screengui itself works fine, but the frames don’t spawn at all in it’s parent. I can’t seem to find any answer.

Script:

local gui1 = Instance.new(“ScreenGui”)

game.Players.PlayerAdded:Connect(function(player)
local playerGui = player:WaitForChild(“PlayerGui”)
gui1.Parent = playerGui
for i, accessory in ipairs(accessories) do
local frame = Instance.new(“Frame”)
frame.Parent = gui1.Parent
frame.Size = UDim2.new(0, 100, 0, 50)
frame.Position = UDim2.new(0, 10, 0, (i - 1) * 60)
frame.BackgroundColor3 = Color3.new(1, 1, 1)
frame.BorderSizePixel = 0
end
end)

4 Likes

Try changing frame.Parent = gui1.Parent to frame.Parent = gui1 This will put the frames inside the ScreenGui, otherwise they are put in the PlayerGui.

2 Likes

still, the frames didn’t spawn

1 Like

Try using pairs instead of ipairs! I never had good experiences with ipairs.

2 Likes

changing ipairs to pairs didn’t really change anything

wait, does the frame not spawn at all or in the wrong place?

1 Like

the frame doesn’t spawn at all

are they in the explorer when you spawn

1 Like

What is accessories, is it a table, a folder, a model,?

1 Like

not even in the explorer, they just don’t exist when spawning

2 Likes

can you look if they spawn in the players startergui

2 Likes

Then what exactly is accessories

2 Likes

This is from the script

local Accessory10 = InsertService:LoadAsset(“6101283635”):GetChildren()[1]
Accessory10.Parent = script.Parent.Parent
table.insert(accessories, Accessory10)

they don’t spawn in the starter gui

id assume accessories is a table

1 Like

starter gui or players player gui?

Try inserting the object with the provided id before runtime and get the children from that.

I think I figured the issue. Is that a local script?

Nope, it’s a regular script is it because it’s regular?

Hm. No a regular script is ok, it might have to the fact that the table might be empty before you access it. can you print accessories?

1 Like