Collapse Sidebar


This function takes an array of Instance|Instances as a parameter and yields until all of assets associated with those instances have loaded. 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 all of the instances in the passed in array (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 places output, but the PreloadAsync function itself will not error and will continue executing until it has processed each passed in instance.


Name Type Default Description

An array of Instances to be preloaded.


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


Return Type Summary

No return

Code Samples

Preloading Assets

In this example a Decal and Sound are preloaded into a game. Once they have finished loading the script will print a message to the output.

local ContentProvider = game:GetService("ContentProvider")

local waitingImage = "rbxassetid://1234561"

local thumbLeft = "rbxthumb://type=Avatar&id=1234&w=100&h=100"
local thumbRight = "rbxthumb://type=Avatar&id=1235&w=100&h=100"

local failedImageLeft = "rbxassetid://1234562"
local failedImageRight = "rbxassetid://1234563"

local labelLeft = script.Parent.LabelLeft
labelLeft.Image = waitingImage

local labelRight = script.Parent.LabelRight
labelRight.Image = waitingImage

local assets = { thumbLeft, thumbRight }

local function setThumb(contentId, status)
	if thumbLeft == contentId then
		labelLeft.Image = Enum.AssetFetchStatus.Success == status and thumbLeft or failedImageLeft
	elseif thumbRight == contentId then
		labelRight.Image = Enum.AssetFetchStatus.Success == status and thumbRight or failedImageRight

	ContentProvider:PreloadAsync(assets, setThumb)