Loading bar doesn't load assets efficiently

I have a loading bar script that loads every Descendant of the game.

It does work, however, the percentage seems to be really off, and it takes way too long for the script to “load” the game when it’s already loaded.

I’ve looked for different methods to load the player’s game more efficiently, but couldn’t find anything. I think I’m missing something.

I want to improve the code by loading the game more efficiently because I think it’s loading assets that have already been loaded, which is why it takes so long.

local assets = game:GetDescendants() local Bar = LoadingScreen.Bar local barText = Bar.TextLabel for i = 1, #assets do	local asset = assets[i]	local percentage = math.round(i / #assets * 100)	if asset:IsA("Folder") then	barText.Text = asset.Name.."..."	end	print(percentage)	TS:Create(Bar, TweenInfo.new(0.2, Enum.EasingStyle.Sine), {Size = UDim2.fromScale(percentage/100, 0.025)}):Play()	ContentProv:PreloadAsync({asset}) end 

Here is a visual representation to get a better understanding:

The numbers below are the percentage of the game that has been loaded. And you can see how low it is seeing as everything looks already loaded!

I found a solution! Instead of loading the WHOLE game itself, I should have loaded the workspace, or even better, a folder in the workspace that contains all of the main assets to be loaded.

Here’s the changed code if anyone was wondering:

local assets = workspace.world:GetDescendants() local Bar = LoadingScreen.Bar local barText = Bar.TextLabel for i = 1, #assets do	local asset = assets[i]	local percentage = math.round(i / #assets * 100)	if asset:IsA("Folder") then	barText.Text = asset.Name.."..."	end	print(percentage)	TS:Create(Bar, TweenInfo.new(0.2, Enum.EasingStyle.Sine), {Size = UDim2.fromScale(percentage/100, 0.025)}):Play()	ContentProv:PreloadAsync({asset}) end 

Instead of loading all of this:
image

I’m only loading this:
image

2 Likes

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