Service · inherits Instance
InsertService
Used to insert assets from the Roblox website.
About InsertService
InsertService is used to insert assets from the Roblox website, typically the
LoadAsset function.
To load an asset, it must be accessible by the creator of the experience
loading it, which can be either a user or group. Should an experience be
uploaded by a different creator, the asset data would not be accessible. See
the LoadAsset() method for more details on
this security check. Note that you should not use this service for loading
API keys or other secrets. Use HttpService.GetSecret instead.
See Also
AssetService, which can provide information about assets you might want to load using InsertService
Methods 6
CreateMeshPartAsync
(meshId: ContentId, collisionFidelity: CollisionFidelity, renderFidelity: RenderFidelity) → MeshPartYieldsCreates a newMeshPartwith specified fidelity values.Creates a new
MeshPartwith specifiedCollisionFidelityandRenderFidelity. BecauseMeshPart.MeshIdis read only, this is the way to create aMeshPartthrough scripts without having to clone an existing one. It throws errors if creation fails.GetFreeDecalsAsync
(searchText: string, pageNum: int) → ArrayYieldsRetrieves a list of free Decals from the Catalog.The GetFreeDecalsAsync function retrieves a list of free
Decalsfrom the Catalog. The return type for this method is very odd, as it returns a single table wrapped in a table.The best way to explain it is to show a visual of the array returned:
[1] = { CurrentStartIndex = 1, -- This can vary depending on the page you input. TotalCount = 21, -- Always 21. Results = { -- All parameters here are pseudo. They can vary depending on the asset. [1] = { Name = "Asset Name", AssetId = 0000000, AssetVersionId = 0000000, CreatorName = "Roblox", }, -- [2], [3], and so on... up to [21] }, }An example for iterating over this list has been provided at the bottom of this page.
Additionally, if you want to insert
Modelsinstead, you can use theInsertService.GetFreeModelsAsyncfunction.Note: The page argument starts at 0. So Page 1 = 0, Page 2 = 1, etc.
GetFreeModelsAsync
(searchText: string, pageNum: int) → ArrayYieldsRetrieves a list of Free Models from the Catalog.The GetFreeModelsAsync function retrieves a list of Free
Modelsfrom the Catalog. The return type for this method is very odd, as it returns a single table wrapped in a table.The best way to explain it is to show a visual of the array returned:
[1] = { CurrentStartIndex = 1, -- This can vary depending on the page you input. TotalCount = 21, -- Always 21. Results = { -- All parameters here are pseudo. They can vary depending on the asset. [1] = { Name = "Asset Name", AssetId = 0000000, AssetVersionId = 0000000, CreatorName = "Roblox", } -- [2], [3], and so on... up to [21] } }An example for iterating over this list has been provided at the bottom of this page.
Additionally, if you would like to insert free
Decals, you can use theInsertService.GetFreeDecalsAsyncfunction.GetLatestAssetVersionAsync
(assetId: int64) → int64YieldsReturns the latest AssetVersionId of an asset for assets created by the place creator. Can be used in combination withInsertService.LoadAssetVersionto load the latest version of a model, even if it gets updated while the game is running.LoadAsset
(assetId: int64) → InstanceYieldsReturns aModelcontaining the asset.The LoadAsset function fetches an asset given its ID and returns a
Modelcontaining the asset. For example, to load this public DogeModel, which has the asset ID 257489726, you can use:local InsertService = game:GetService("InsertService") local Workspace = game:GetService("Workspace") local assetId = 257489726 local model = InsertService:LoadAsset(assetId) model.Parent = WorkspaceCalls 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
pcallto catch these kinds of errors.local InsertService = game:GetService("InsertService") local Workspace = game:GetService("Workspace") local assetId = 257489726 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!") endSecurity Check
An asset loaded by this function must meet one of the following:
- The asset must be created or owned by the game creator.
- The asset must be shared by the asset owner.
- The asset must be owned by Roblox.
Additionally, benign asset types such as t-shirts, shirts, pants and avatar accessories are loadable from any game as they are
OpenUse.To load assets which do not meet the above criteria, such as free Models published on the Store, you must use
AssetService.LoadAssetAsyncand enableAssetService.AllowInsertFreeAssets.See also:
AssetService.GetBundleDetailsAsync, to find out which assets are associated with a bundle.- For plugins, see
DataModel.GetObjects
LoadAssetVersion
(assetVersionId: int64) → InstanceYieldsReturns a model inserted intoInsertServicecontaining the asset with the given assetVersionId.
InsertService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.