Help with ContentProvider

Hello! I’m trying to make a script that pre loads all the assets in my game before a black screen fades out. I’ve made this script that should load all the assets:

local TweenService = game:GetService("TweenService")

local ContentProvider = game:GetService("ContentProvider")

local BG = script.Parent.BG

spawn(function()

ContentProvider:PreloadAsync({

game:GetService("Workspace"),

game:GetService("Lighting")

})

end)

The problem is that at first, I don’t know if this script works and how could I make my “BG” disappears after everything is loaded?
image

just use tween service to make it fade away

I know image
The problem is if the assets will load and how to detect that they all loaded

i think you could use a pcall function when preloading the assets, im not certain it will fire exactly when everyhthing is loaded but try it

ContentProvider.RequestQueueSize returns the amount of assets needed to be loaded. You could use a for loop that increases an integer every time it looped through an asset.

1 Like