game:IsLoaded() vs ContentProvider:PreloadAsync

Hi, I want to preload all assets in my game before the client spawns for the first time.
Otherwise, my client’s character will sometimes spawn with invisible meshparts due to no type of waiting/loading.

For game:IsLoaded(), the wiki says,
“The Loaded event fires when all initial Instance|Instances in the game have finished replicating to the client.”

Does that mean all assets such as sounds/meshes/decals/etc are 100% loaded and ready to use, or just that the client recognizes their existence? (Acknowledges that there is a meshpart, but it may or may not be visible yet)

Basically, is IsLoaded() just an easy way to load every asset exactly like PreloadAsync without having to put every unique asset in a table and run it through the function?

2 Likes

No. game.Loaded and game:IsLoaded describe the existence of all static Instances (whether or not they have all replicated from the server), not necessarily their contents’ loading status.

9 Likes

I would recommend doing this by default. There will probably be a set of “core” components, like the first UI a player sees, you will want to guarantee to have loaded. Everything else can be started but can have a skip button if the player has a slow connection.

4 Likes

It doesn’t make too much difference to you as the developer if you make it automated. I have the script trawl through assets that are in ReplicatedStorage and any GUIs and pull out all sounds, images, meshes and unions, and preloads those.

Preloading has the added benefit of being able to check the progress.

1 Like

You should try to make most of your game work without preloading anything as part of an introductory screen. You always want to cut down on any initial wait time.

game.IsLoaded should only be used in loading screens to determine when the map has been loaded in so you aren’t showing the user an empty skybox. It doesn’t preload any assets.

3 Likes

game:IsLoaded/game.Loaded → Determines when server has replicated instances to the client.
ContentProvider::PreloadAsync → Preloads content so it’s available on priority for download.

There is no “vs”. They serve two vastly different functions. Furthermore, “preloading all my game’s assets” doesn’t make it a preload anymore, it just amounts to regular loading.

Preloading your entire game is bad. You should only use it on assets immediately available to clients (e.g. loading screens) and preloading wasn’t made so you could pass your entire game through it. That being said, wait time to get into a game should be minimal (as pointed out above) - people will get impatient and leave.

4 Likes

@colbert2677 I feel reprimanded :sweat_smile:

Thanks for the responses, everyone. I think I have a better understanding now.

2 Likes

mark a solution so people know where to look if they have the same question. not asking you to mark mine or anything, dont get the wrong idea.

These functions have relatively sufficient documentation on the Developer Hub to describe their functions. You can also use them at the same time if you so please. In the end though, whatever you choose, try to ensure that loading times are low. Only preload a couple assets if its necessary, otherwise let the client do the downloading itself.

1 Like