# of Instances that DataModel:IsLoaded() waits for

Is there a way to get the amount of Instances that DataModel:IsLoaded() waits for?
and is there a way to get the amount of Instances that have loaded out of the total amount?

I have this code

repeat
	print('Game Is Loading')
	wait()
until game:IsLoaded()

and a Loading Bar would progress depending on

TotalLoaded/TotalToLoad
1 Like

I don’t believe there is with game:IsLoaded(). If you’re preloading assets though there is.

1 Like

So how do games do like, “Game Loading: xxx Assets”

There isn’t. If you’e just trying to match a loading bar with the load time then look at this.

Games like that preload all their assets.

1 Like

So, I would create a ContentService:PreloadAsync() and Preload all the instances in the game
How would I get a Table of all the instances in the game?

1 Like

The table of instances in the game are things you’re wanting to load before the player joins, images, sounds, meshes, etc.

You would have a big table of the IDs you are going to preload, and each time one is done, add it to the number of completed and increment the bar.

That’s what I did here for this games intro: xVBQAbOn1a

1 Like

So does that work for Parts, Uis, and such? If I did
a for loop for everything in the workspace and put it in a table, basically preloading the parts.

To clarify something: there is no way to check how many instances the client is waiting for. All that replication logic is internal. IsLoaded tells you when the server has finished initial replication to the client, but it doesn’t give you any numbers.

ContentProvider is what you can use if you want to prioritise an asset to be downloaded or make it download in the priority queue if it hasn’t been used at least once in the game, however this pertains to assets from the CDN, not to instances. That’s stuff like shirts, pants, audio, whatever.

When it comes to parts, only non-primitives will get downloaded, so that’s MeshParts and UnionOperation parts (Unions are uploaded as an asset to the website and must be downloaded). Anything else falls under general replication and does not need any downloading done for it, thus PreloadAsync on a model with no assets is meaningless.

You can check the preload handling process by going through a table of instances one-by-one and passing them as a single-entry table to ContentProvider, but zeuxcg spoke against doing this a bit ago. See this post for more information:

If you ever use PreloadAsync, never pass your entire game through it. PreloadAsync is only meant, as the name of the method states, to prioritise something in the download queue. If you prioritise everything, it’s the same as prioritising nothing. PreloadAsync should only be used for assets that the client should immediately see (loading screen icons, menu textures, so on).

You can also put models in ReplicatedFirst if you want them to be the first things replicated to the client, however the instances here are only available to the client, they aren’t replicated back to the server.

2 Likes