Loading screen showing how many assets are left to load

Hello developers,

I’m currently looking on how to make a loading screen for my game. But i was wondering how could i make a loading screen that shows how many assets are left to load. And how could i do this in a script?

Thanks in advance!

1 Like

There is a function to preload assets (then they work immediately) called ContentProvider:PreloadAsync(). :hugs:

Could i show you an example on what i mean with my topic?

1 Like

As stated from @Wixonic_FR 's post, use ContentProvider’s preloadasync function, then insert your callback function to tell you how many assets left to load

local assets = {
  --put the assets 
}

local TotalAssets = #assets
local AssetsRemaining = TotalAssets

function TellRemainingAssets()
   AssetsRemaining = TotalAssets - 1
   print(AssetsRemaining)
end

ContentProvider:PreloadAsync(assets, TellRemainingAssets)

Untested but according to documentation it should work

2 Likes

Unfortunately you have to put manually all the assets you want to load, otherwise it won’t work.

local ContentProvider = game:GetService("ContentProvider")

local AssetsToLoad = {
    12345678,
    23456781,
    -- And all assets...
}

local AssetsLeft = #AssetsToLoad

for _, Asset in pairs(AssetsToLoad) do
    ContentProvider:PreloadAsync({"rbxassetid://" .. Asset})
    AssetsLeft -= 1
end

I found a old topic about this, could this also work?

local WorkspaceAssets = workspace:GetDescendants()
local PlayerGuiAssets = localPlayer.PlayerGui:GetDescendants()

for Id,Asset in pairs(WorkspaceAssets) do
	local AssetsLeft = #WorkspaceAssets - Id + 1
	
	if AssetsLeft == 1 then
		new.Container.AssetsProgress.Text = "Loading... (1 Asset Left)"
	else
		new.Container.AssetsProgress.Text = "Loading... ("..AssetsLeft.." Assets Left"
	end
1 Like
  1. I don’t think this works
  2. I’m sure it doesn’t work for images and sounds