Does not create imagebutton

The imagebutton is not created and parented to the scrolling frame
Script:

local player = script.Parent.Parent.Parent.Parent.Parent
local Item = game.ServerStorage.Inventory[player.Name]:GetChildren()

print(player.Name)

for i = 1, #Item do
	local NewItem = script:WaitForChild("ImageButton"):Clone()
	NewItem.Name = Item[i].Name
	NewItem.Image = Item[i].TextureId
	NewItem.TopLabel.Text = Item[i].Name
	NewItem.Parent = script.Parent
end

there are no error

1 Like

Does NewItem exist? And also does the script even run

it does​​​​​

Can u send a screenshot of your explorer so I can see how you have it and so I can test it out

image

One thing I just noticed is that when you made the player variable, i dont recommend using that method to get the player try

local player = game.Players.LocalPlayer

it is a server script​​​​​

can you tell me what you’re trying to do?

Try using:

local player = script.Parent.Parent.Parent.Parent.Parent
local Item = game.ServerStorage.Inventory[player.Name]:GetChildren()

print(player.Name)

for i = 1, #Item do
	local NewItem = script.ImageButton:Clone()
	NewItem.Name = Item[i].Name
	NewItem.Image = Item[i].TextureId
	NewItem.TopLabel.Text = Item[i].Name
	NewItem.Parent = script.Parent
end

WaitForChild isn’t needed in server Script

still no work​​​​​

I think it’s because print(player.Name) is erroring, try removing it and see if it works

it does not error i tried it work it isnt print​​​​​

Hopefully this will work then:

local player = script.Parent.Parent.Parent.Parent.Parent
local Items = game.ServerStorage.Inventory[player.Name]:GetChildren()

print(player.Name)

for _, Item in Items do
	local NewItem = script.ImageButton:Clone()
	NewItem.Name = Item.Name
	NewItem.Image = Item.TextureId
	NewItem.TopLabel.Text = Item.Name
	NewItem.Parent = script.Parent
end

can you tell me what you’re trying to do so I know exactly what this code is for and then test it properly.

no luck​​​​​​

If the Inventory is empty the loop won’t run, please show us the Inventory so we can help you

it is not empty
image

What isn’t working though? I’m not seeing any potential issues at the moment

it does not create the image button and supposed to parent to scrollingframe
image

the image buttons are getting parented to the image buttons. change the parent to .Parent.Parent

EDIT: Ive just read the above bit, move the code to a local script.