Roblox UtilitiesDevlHub Roblox Documentation

Class

InsertService

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

Used to insert assets from the Roblox website.

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

Properties 1#

AllowInsertFreeModelsbooleanIndicates whether ''Free Models'' can be inserted into the game.ReadSafeDeprecatedNotReplicatedNotBrowsable

AllowInsertFreeModels: boolean#

NotReplicatedNotBrowsableDeprecatedReadSafeDeprecated

Deprecated. This item was never released. Do not use it in new work.

The AllowInsertFreeModels property toggles whether ''Free Models'' can be inserted into the game, regardless of whether the place owner owns the asset.

Methods 17#

ApproveAssetIdDeprecated. Accepts an asset ID for InsertService approval; calling it has no effect.Deprecated
ApproveAssetVersionIdDeprecated. Accepts an asset version ID for InsertService approval; calling it has no effect.Deprecated
CreateMeshPartAsyncCreates a new MeshPart with specified fidelity values.Yields
GetBaseCategoriesDeprecatedYields
GetBaseSetsReturns an array of dictionaries, containing information about various Roblox approved sets.DeprecatedYields
GetCollectionReturns the most recently uploaded models in the specified category.DeprecatedYields
GetFreeDecalsRetrieves a list of free Decals from the Catalog.DeprecatedYields
GetFreeDecalsAsyncRetrieves a list of free Decals from the Catalog.Yields
GetFreeModelsRetrieves a list of Free Models from the Catalog.DeprecatedYields
GetFreeModelsAsyncRetrieves a list of Free Models from the Catalog.Yields
GetLatestAssetVersionAsyncReturns the latest AssetVersionId of an asset for assets created by the place creator. Can be used in combination with InsertService:LoadAssetVersion() to load the latest version of a model, even if it gets updated while the game is running.Yields
GetUserCategoriesDeprecatedYields
GetUserSetsReturns an array of dictionaries, containing information about sets owned by the user.DeprecatedYields
InsertInserts Instance into Workspace.Deprecated
LoadAssetReturns a Model containing the asset.Yields
loadAssetDeprecatedYields
LoadAssetVersionReturns a model inserted into InsertService containing the asset with the given assetVersionId.Yields

ApproveAssetId(assetId: int64): ()#

DeprecatedDeprecated

Deprecated. This item is deprecated. Do not use it for new work.

Deprecated. Accepts an asset ID that was once used to approve assets for InsertService. Calling it has no effect. Retained only for backward compatibility; do not use it in new work.

NameTypeDefaultDescription
assetIdint64The ID of the asset.
Returns
  • ()

ApproveAssetVersionId(assetVersionId: int64): ()#

DeprecatedDeprecated

Deprecated. This item is deprecated. Do not use it for new work.

Deprecated. Accepts an asset version ID that was once used to approve assets for InsertService. Calling it has no effect. Retained only for backward compatibility; do not use it in new work.

NameTypeDefaultDescription
assetVersionIdint64The version ID of the asset.
Returns
  • ()

CreateMeshPartAsync(meshId: ContentId, collisionFidelity: CollisionFidelity, renderFidelity: RenderFidelity): MeshPart#

Yields

Creates a new MeshPart with specified CollisionFidelity and RenderFidelity. Because MeshPart.MeshId is read only, this is the way to create a MeshPart through scripts without having to clone an existing one. It throws errors if creation fails.

NameTypeDefaultDescription
meshIdContentIdMesh asset ID.
collisionFidelityCollisionFidelitySet MeshPart.CollisionFidelity.
renderFidelityRenderFidelitySet MeshPart.RenderFidelity.
Returns

GetBaseCategories(): Array#

YieldsDeprecatedDeprecated

Deprecated. This item is deprecated. Do not use it for new work.

Returns
  • Array

GetBaseSets(): Array#

YieldsDeprecatedDeprecated

Deprecated. Sets have been removed from Roblox.

Returns an array of dictionaries, containing information about various Roblox approved sets.

Returns
  • Array — An array of dictionaries containing information about Roblox-approved sets.

GetCollection(categoryId: int64): Array#

YieldsDeprecatedDeprecated

Deprecated. Sets have been removed from Roblox.

Returns the most recently uploaded models in the specified category.

NameTypeDefaultDescription
categoryIdint64The ID of the set (category) to retrieve models from.
Returns
  • Array — An array of the most recently uploaded models in the specified set.

GetFreeDecals(searchText: string, pageNum: int): Array#

YieldsDeprecatedDeprecated

Deprecated. Use GetFreeDecalsAsync() instead.

Retrieves a list of free Decals from the Catalog.

NameTypeDefaultDescription
searchTextstringString used to search for free decals in the Catalog.
pageNumintThe page number in the Catalog to return.
Returns
  • Array — A single table (of returned free decals) wrapped in a table.

GetFreeDecalsAsync(searchText: string, pageNum: int): Array#

Yields

The GetFreeDecalsAsync function retrieves a list of free Decals from 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:

Luau
[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 Models instead, you can use the InsertService:GetFreeModelsAsync() function.

Note: The page argument starts at 0. So Page 1 = 0, Page 2 = 1, etc.

NameTypeDefaultDescription
searchTextstringString used to search for free decals in the Catalog.
pageNumintThe page number in the Catalog to return.
Returns
  • Array — A single table (of returned free decals) wrapped in a table.

GetFreeModels(searchText: string, pageNum: int): Array#

YieldsDeprecatedDeprecated

Deprecated. Use GetFreeModelsAsync() instead.

Retrieves a list of Free Models from the Catalog.

NameTypeDefaultDescription
searchTextstringString used to search for free models in the Catalog.
pageNumintThe page number in the Catalog to return.
Returns
  • Array — A single table (of returned free models) wrapped in a table.

GetFreeModelsAsync(searchText: string, pageNum: int): Array#

Yields

The GetFreeModelsAsync function retrieves a list of Free Models from 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:

Luau
[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 the InsertService:GetFreeDecalsAsync() function.

NameTypeDefaultDescription
searchTextstringString used to search for free decals in the Catalog.
pageNumintThe page number in the Catalog to return.
Returns
  • Array — A single table (of returned free models) wrapped in a table.

GetLatestAssetVersionAsync(assetId: int64): int64#

Yields

Returns the latest AssetVersionId of an asset for assets created by the place creator. Can be used in combination with InsertService:LoadAssetVersion() to load the latest version of a model, even if it gets updated while the game is running.

NameTypeDefaultDescription
assetIdint64The ID of the asset to retrieve the latest version for.
Returns
  • int64 — The latest asset version ID for the specified asset.

GetUserCategories(userId: User): Array#

YieldsDeprecatedDeprecated

Deprecated. This item is deprecated. Do not use it for new work.

NameTypeDefaultDescription
userIdUser
Returns
  • Array

GetUserSets(userId: User): Array#

YieldsDeprecatedDeprecated

Deprecated. Sets have been removed from Roblox.

Returns an array of dictionaries, containing information about sets owned by the user. This includes

  • Sets the user is subscribed to.
  • Sets that the user created.
  • A single set containing the models created by the user.
  • A single set containing the decals created by the user.

Note:

  • All values in the dictionaries are strings, even if they are a number.
Name Description
Name The name of the set.
Description The description of the set.
ImageAssetId An assetId for the icon of the set.
CreatorName The creator of the set.
AssetSetId The set's unique ID on the website.
CategoryId Identical to AssetSetId
SetType The type of set that this set is.
NameTypeDefaultDescription
userIdUserThe ID of the user whose sets to retrieve.
Returns
  • Array — An array of dictionaries containing information about the user's sets.

Insert(instance: Instance): ()#

DeprecatedDeprecated

Deprecated. This function has been superseded by InsertService:LoadAsset() which should be used in all new work.

This function is a legacy method used to insert an Instance into Workspace.

NameTypeDefaultDescription
instanceInstanceThe Instance to insert into Workspace.
Returns
  • ()

LoadAsset(assetId: int64): Instance#

Yields

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:

Luau
local InsertService = game:GetService("InsertService")
local Workspace = game:GetService("Workspace")

local assetId = 257489726
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.

Luau
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!")
end

Security 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:LoadAssetAsync() and enable AssetService.AllowInsertFreeAssets.

See also:

NameTypeDefaultDescription
assetIdint64The asset ID of the asset being loaded.
Returns
  • Instance — An instance of the loaded asset.

loadAsset(assetId: int64): Instance#

YieldsDeprecatedDeprecated

Deprecated. This function is a deprecated variant of InsertService:LoadAsset() which should be used instead.

NameTypeDefaultDescription
assetIdint64
Returns

LoadAssetVersion(assetVersionId: int64): Instance#

Yields

Returns a model inserted into InsertService containing the asset with the given assetVersionId.

NameTypeDefaultDescription
assetVersionIdint64The version ID of the asset to load.
Returns
  • Instance — A Model containing the asset at the specified version.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed