Proper Way To Preload Assets

Ah, so you are saying I can pass that function a gui item, such as a frame, and it will recursively preload those. Good to know. Thank you.

Some of my assets are gui, but other assets are content, such as models, or surface guis.

Things appear to be loading normally (except perhaps on a phone, which seemed to load and lag very slowly - not sure if that is just my phone or not).

1 Like

Any object works! You could call it on i.e. workspace to load all unions / decals / meshes / whatever if you wanted to. (Don’t do that though obviously) Or on a specific model.

7 Likes

Credit to @ONLYTW3NTYCH4RACT3R5, who advised me to put all the things I want to load under a folder. And attach this local script:

game:GetServiceContentProvider':PreloadAsync(workspace.FOLDERNAME:GetDescendants());

Hope this helps.

11 Likes

I believe you could just use workspace.FOLDERNAME and it would load recursively from there.

1 Like

Out of curiosity, why not call it on the DataModel or workspace lol?

In the context of a loading screen, you do not want to wait until the entire game is loaded. On mobile that could mean waiting minutes or never complete at all.

2 Likes

Sorry to bump such an old thread, do you think there’s any problem with calling PreloadAsync with the PlayerGui so that it looks all the UI in it as 90% of my UI are images.

What about if the game is a PC or Xbox only game? Would having a decent loading time of around 10-15 seconds be bad?

That makes no sense to me though - I figured people would want to allow a game to load so everything isn’t grey.

But then again, that’s a personal preference of mine.

Loading time is unfortunate… That is part of the reason why apps on mobile devices need to be downloaded - usually on wifi - and installed. I believe that Roblox would benefit greatly from following the traditional patterns of games on mobile devices - traditions tested by time.

While it is amazing that Roblox games can be downloaded on the fly, allowing users to install games they commonly play or developers to choose that their game are best expierienced preloaded, would be better. Once installed they will load very quickly, and perhaps hardly need to stream anything.

Installing games also opens new doors to performance improvements. Lua could be compiled for easily 10 times the script speed. Perhaps developers would want their game to be installed for that reason alone? Bigger games could be built, with more complex scripts. This would also allow for my favorite advantage, more Roblox features to be implemented in Lua, where with the new package system it could be enhanced with useful features by the community, modified to fit niche needs, and optimized to remove unused or dated features.

Allowing Roblox games to be installed like apps also makes the platform owners happy. I’m sure Apple would be happy to be rid of arbitrary code execution on their platforms, and other platforms like Microsoft’s Xbox or perhaps even others Roblox hasn’t been allowed on yet for security reasons.

Perhaps Roblox would like to try a more innovative hybrid approach, compiled scripts and other assets the developer specifies would be screened by the platform and installed before the game is run, while the rest can be loaded at runtime, allowing game developers to still rapidly develop and deploy updates.

What do you developers think? Would this be a good direction for Roblox to go? The proper way to load assets isn’t at a loadscreen, it is in the background. Updates while the users arn’t looking, and installs while they browse other games and talk to friends, I say!

7 Likes

Does it matter where the object is located, such as ServerStorage, Tools, etc? Just wondering if I can preload by referencing any object in any location.

I’m pretty sure it doesn’t. Preload means you’re getting the asset ready so that it can be shown to a client immediately. Personally, I haven’t had a use case for preloading anything outside of the PlayerGui or only a small handful of parts in the Workspace.

It works on anything in the client datamodel.

Obv serverstorage is only visible to the server so no.

1 Like

Completely disagree. Roblox is a game streaming platform. This is a core tenant of how we operate, and it means that players never have to wait to download a game or install an update. It means there is little friction for developers to release updates which means that they can improve games faster.

Many players still suffer from poor Internet connections. This will become less of a problem as Internet connectivity improves and becomes a given. There are some things we can and are doing in the interim, like optimizing our network traffic and downloading simplified versions of assets while the game fully loads. But we will not take a step backwards and move away from our streaming model.

21 Likes

Just wondering is there a way to preload a StarterCharacter?

What do you mean by preload a StarterCharacter? You can call :PreloadAsync() on the character model, which will load all textures and sounds automatically.

2 Likes

My game uses a StarterCharacter placed in the StarterPlayer folder. I would like to have all the mesh parts of that character model preloaded. Can I just do this:

ContentProvider:PreloadAsync(game.StarterPlayer.StarterCharacter)
1 Like

Yes you can. PreloadAsync will pass all the descendants of an Instance as well, so passing the StarterCharacter will pass its descendants to be downloaded on priority as well.

4 Likes

Hello, I wanted to point out, that the documentation for PreloadAsync, is not accurate.

The documentation states that PreloadAsync accepts an array of Instances, but then demonstrates the API’s usage by passing an array of strings.

I tried that technique, and it works. Suggest to update the documentation to reflect the actual types accepted by the API.