Loading bar go up when each asset is loaded?

So I am making this loading screen, and this is part of my code:

while true do
repeat 
	wait(0.001)
	num = num + math.random(0.3,1)
	script.Parent.Size = UDim2.new(0,num,0,50)
	script.Parent.Parent.Text.Text = content.RequestQueueSize.." assets left"
until script.Parent.Size == script.Parent.Parent.Size

	if content.RequestQueueSize == 0 then
	gui.Frame:TweenPosition(UDim2.new(0,0,1,0))
	wait(1)
	gui:Destroy()
end

end

I want the bar to go up when each asset is loaded, but don’t know how.

I have tried for and while loops, they may work, but I don’t know how to format it for this.

Any help?

What about adding the assets into a table and then checking if they can be found or on like

local assets = {
  "ImageButton",
  "ImageLabel"
}

for i,v in pairs(assets)do
   script.Parent:WaitForChild(v)
   table.remove(assets, i)
end

print("Loading has completed")

Idk if that could work because I just wrote it right now

1 Like

Im looking for a way that detects when an asset has moved from the RequestQueue, then making the bar larger.

I mean adding names of the assets and make it try to find it. You could improve it by making it try to wait until it can find the asset inside the PlayerGui.

Here is what I use to make a loading bar that increases per asset loaded. You’re on the right track tho.

You divide the bar’s full size by the amount of assets loaded.

Idk how to make it detects when as asset has moved from the RequestQueue but I know how you could you make the bar larger

First you count how many assest you want to check if it’s has loaded or no then you add it to a loadedassest variable like

loadedAssests = i -- Assests that has been loaded in a for i,v in pairs()do loop
assets = #assests -- Assests in the game that you added in a table

script.Parent.Text = i.." / "..assests -- Changing the text if you have in the bar
script.Parent.Size = UDim2.fromScale(loadedassests/assets,1) -- Changing the size of the bar
1 Like