Does not create imagebutton

it will not read the inventory in server storage​​​​

I rewrote the script, maybe it will work now:

local player = script:FindFirstAncestorWhichIsA"Player"

if not player then error"Script must be a descendant of a Player to work correctly" end

local items = game:GetService"ServerStorage".Inventory[player.Name]:GetChildren()

local button = script.ImageButton
local scrollingFrame = script.Parent

for _, item in items do
   local button = button:Clone()
   button.Name = item.Name
   button.Image = item.TextureId
   button.TopLabel.Text = item.name
   button.Parent = scrollingFrame
end

no error and not work​​​​​​

Unfortunately this issue seems to be quite complicated and I don’t have enough time to continue helping you today. I wish you good luck in finding the solution though! :slightly_smiling_face:

inventory system​​​​

update: it work whenever i reset but not when game load

Well there’s your problem. May I ask why exactly are you handling client-sided UI changes in a server script?

If you’re trying to send a player’s “inventory” that’s on the server, simply use RemoteEvents to send the inventory table to the client and then take that table to populate your ScrollingFrame.

it works but only when i reset how can i fix?

Its probably because the client (gui stuff) loads faster than the Instances, so when your script runs the first time, there will be 0 instances in ServerStorage. It fixes the issue because your script will run again due to a property in the gui called “ResetOnSpawn”.

how can i fix this?​​​​​

look you “GUI” and disable the property “ResetOnSpawn” and try again i think that should fix it

does not work​​​​​

If you want it to happen on the first attempt, your best way might probably do a ChildAdded Event, which should run if something gets added into the folder. Not sure if it works

local player = script.Parent.Parent.Parent.Parent.Parent
local Item = game.ServerStorage.Inventory:WaitForChild(player.Name)

Item.ChildAdded:Connect(function()
	local button = button:Clone()
	button.Name = item.Name
	button.Image = item.TextureId
	button.TopLabel.Text = item.name
	button.Parent = scrollingFrame
end)
1 Like

thank u bro​​​​​

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.