Mass gathering data automatically from something in Server Storage

So I’m trying to make this script which automatically generates GUI images on the start of a game for every item in a folder in Server Storage, however I do not know how to index the item in Server Storage, how would I go about with this?

What I have so far (which is a MASSIVE mess
local SS = game:GetService("ServerStorage")
local RS = game:GetService("ReplicatedStorage")
local Name = RS:WaitForChild(script.Parent.Parent.Name)

local Info = script.Parent.Parent.Parent:WaitForChild("Info")
local ItemImage = script.Parent.Parent.Parent:WaitForChild("Info").ItemImage
local ItemPrice = ItemImage.Parent.ItemPrice
local ItemName = ItemImage.Parent.ItemName
local ValuePrice = ItemImage.Parent.Price

local SelectedItem = script.Parent.Parent.Parent:WaitForChild("SelectedItem")
local BuyButton = ItemPrice.Parent.Buy

local GetImage = Name.GetImage
local GetInfo = Name.GetInfo
local GetRequired = Name.GetRequired

local Template = script.Parent.Template

local maxCountbin = script.Parent.WeaponsCount
local maxCount = maxCountbin.Value

maxCountbin:Destroy()

--

while true do
	
	if #script.Parent:GetChildren() < maxCount - 3 then
		
		GetImage:FireServer() -- stopped here because I didn't know what to do lol

	else
		
		script:Destroy()
		
	end
end

What is it that you are trying to do with this If statement?

1 Like

I’m making it so that the script destroys itself when all the info has been gathered

There are better options for that. You can try using a For Loop.

As an example:

for i,v in pairs(script.Parent:GetChildren() do
     --code to create the GUI objects
do
1 Like

After the for loop itterates through everything in script.Parent:GetChildren() it will move on, and then you can run code to destroy the script.

1 Like

I think what I could do to make it easier, is to have a copy inside of ReplicatedStorage when the game starts, have its data read and fed into the GUI, then delete the copy in ReplicatedStorage so no hackers can get their hands on it