Bit of a niche issue, but I am trying to use ContentProvider:PreloadAsync() to preload necessary assets into my game, but I am having an issue since I can’t preload assets unless I have a reference to them, and I can’t get a reference to them if they aren’t loaded.
Basically making a table of objects to be preloaded too early will error since the instances I want to preload haven’t been parented, so I need a way to make sure everything in the game has been parented and can be referenced, just not rendered yet.
How exactly does this work, because this is what I was currently using in combination with PreloadAsync, and it didn’t work like you are saying it does.
I think the issue might be with the difference between IsLoaded and Loaded, what is the different between these two?
Loaded is an event that can be connected to an function e.g: :Connect(function)
game:IsLoaded() returns a boolean that tells you if the game is loaded.
I think replicatedFirst is the best way to do things as waiting for everything to load defeats the purpose of preloading.
What behaviour are you seeing? You should use this in ReplicatedFirst, and the docs say that game.Loaded will fire once all instances have finished replicating. If you didn’t use this in ReplicatedFirst, the script won’t run until all instances have loaded.
So you’re basically saying: “If not everything has replicated by the time this script runs, wait until everything has replicated.”
game.Loaded fires when all initial instances are replicated, not when every instance in the DataModel has been replicated.
@Mr_Spokes Consider if you can use Instance:WaitForChild to wait for the instances to exist, or if you can write your code to run when instances are created.
If you absolutely need all the instances before your code runs and don’t want to use WaitForChild(), you can try communicating the number of instances or a table of the instances from the server to the client and waiting until they match that of the client’s.