Accuracy Vs Load time - ContentProviderService

Hey developers! I have been working on making a loading screen and there is around 1380 assets that need to be loaded (at the time I am writing this).

I have been working on Text that provides the Number of loaded assets at that time…

I have developed 2 ways to do this, and heres why:

One of the methods, Is recommended by Roblox docs page, and it’s Accuracy is spot on. Its load time though, is awfully long, and takes around a minute to load all the assets.

The 2nd method, loads everything really quickly, but the count Accuracy given isn’t as accurate as the first method…

First Method’s code & Video:

(It does reach the Number 1,380, I just trimmed the video down and cut it off the little end by accident)

local AssetsInGame = {}
local NumberAt = 0
local MaxNumber = #AssetsInGame



for i, v in AssetsInGame do 
	ContentService:PreloadAsync({v})
	NumberAt += 1
	script.Parent.MainText.Text = "Loading ("..NumberAt.."/"..MaxNumber..") . . ." 
end


Second Method’s Code & Video:

(1,329 is the final number and it never fully reach the max number any time I play test. The number changes each play test in the 1,250 - 1,360 range)

local AssetsInGame = {}
local NumberAt = 0
local MaxNumber = #AssetsInGame


local callback = function(assetId, assetFetchStatus)
	if table.find(AssetsInGame, assetId) then
		table.remove(AssetsInGame, table.find(AssetsInGame, assetId))
		NumberAt += 1 
		
		script.Parent.MainText.Text = "Loading ("..NumberAt.."/"..MaxNumber..") . . ." 
	end
	
end

ContentService:PreloadAsync(AssetsInGame, callback)


So my question is. Is there a way to merge these 2 to keep a quick load in time, while keeping Accuracy?

Any help is much appreciated!

1 Like

You can use the second method and remove the table methods, they aren’t needed.

Code:

local AssetsInGame = {}
local assetsLoaded = 0
local assetCount = #AssetsInGame

local function callback(assetId, assetFetchStatus)
	assetsLoaded += 1 
		
	script.Parent.MainText.Text = "Loading (".. assetsLoaded .."/".. assetCount ..") . . ." 	
end

ContentService:PreloadAsync(AssetsInGame, callback)
1 Like

I did try this, just right after making this post to see if it would do anything as I also thought that was the issue. It doesn’t effect anything with accuracy, and they been removed going forward

1 Like