Better alternative to game:IsLoaded?

I am making a more advanced loading screen, and part of my code includes:

if game:IsLoaded() then
gui:Destroy()
end

However, the game isn’t actually loaded. There are dozens more assets that need to be loaded, like the custom camera, the builds, the gui’s etc…

I was wondering if there was a better solution to this, rather than game:IsLoaded()?

1 Like

Don’t rely on that then, use game.ContentProvider:PreloadAsync() which takes an array of instances and loads all of them (yielding till they have loaded for a client) and divert the player’s camera until then or destroy the frame or something after that.

 local CP = game:GetService("ContentProvider")
 Cp:PreloadAsync({workspace}) -- yields till descendants have loaded
 gui:Destroy()

Remember to use it only for really important assets, you don’t want to give players long loading times!

13 Likes

You can do game.Loaded:Wait() to wait until the game loads or use the content provider and check if the request queue size is 0.

if contentProvider.RequestQueueSize == 0 then 

    --code

end

Those are alternatives, but you should use what @XxELECTROFUSIONxX suggested just to be sure. But, don’t preload too many instances as it just ruins its purpose!

4 Likes