This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
The LoadAsset function fetches an asset given its ID and returns a
Model containing the asset. For example, to load this public Doge
Model, which has the asset Id 257489726, you can use:
local assetId = 257489726 local InsertService = game:GetService("InsertService") local model = InsertService:LoadAsset(assetId) model.Parent = workspace
Calls to this function may fail if a server providing a model is having problems. As such, it’s generally a good idea to wrap calls to this function in
pcall to catch these kinds of errors.
local assetId = 257489726 local InsertService = game:GetService("InsertService") local success, model = pcall(InsertService.LoadAsset, InsertService, assetId) if success and model then print("Model loaded successfully") model.Parent = workspace else print("Model failed to load!") end
An asset loaded by this function must be created or owned by either the game creator or Roblox. Additionally, benign asset types such as t-shirts, shirts, pants and avatar accessories are loadable from any game as they are public.
AssetService/GetBundleDetailsAsync, to find out which assets are associated with a bundle.
- For plugins, see
The asset Id of the asset being loaded
An instance of the loaded asset
local assetId = 82353 game:GetService("InsertService"):LoadAsset(assetId).Parent = game.Workspace