What is the better option to load all assets

i have a loading script that loads all assets but i am not sure which one is better and more optimal for the game loading system

local Assets = game:GetDescendants() 

for i = 1, #Assets do -- from index 1 to the last asset number, it does
	local asset = Assets[i] -- here is to get the current asset loading

	ContentProvider:PreloadAsync({asset})
	
	UI1.MainFrame.LoadingText .Text = ""..i.."/"..#Assets..""
	
end

or

local Assets = game:GetDescendants() 

for i = 1, #Assets do -- from index 1 to the last asset number, it does
	local asset = Assets[i] -- here is to get the current asset loading

	ContentProvider:PreloadAsync({workspace})
	
	UI1.MainFrame.LoadingText .Text = ""..i.."/"..#Assets..""
	
end

the workspace one loads slower and as far as I can see it dosen’t have a difference but the assets one loads it faster and does the same thing but loads all assets in the game not just in the workspace

In the second one, you Preload the whole workspace for every Descendant in the game. For example, if there are 1000 parts in your game, it will preload the whole workspace (all the 1000 parts) 1000 times each. That is a lot of useless loading. You should use the first one, as it only loads every asset once.

thanks for the help

i thought the same but wasnt sure

The 2nd one would work better if you removed the for loop.

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