PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

PreloadAsync

Yields until all of the assets associated with the given Instance|Instances have loaded and takes an array of Instance|Instances as a parameter.

This can be used to pause a script and not use content until it is certain that the content has been loaded into the game.

When the function is called, the engine will go through the array of instances (and all of the descendants of the passed-in instances). If any of the instances have a property that defines a link to content, such as a Decal or a Sound, then the function will attempt to load the asset from the Roblox website. If any of the assets fail to load, an error message will appear in the output, but the PreloadAsync function itself will not error and will continue executing until it has processed each passed-in instance.

Parameters

Name Type Default Description

An array of Instances to be preloaded.

nil

The Lua function to be called on completion of each asset request

Returns

Return Type Summary

No return


Code Samples


Preloading Assets

In this code sample, several textures and sounds are preloaded using Sound and Decal instances, as well as plain /articles/Content|Content. Furthermore, 50 random user avatars are preloaded.