Class
InsertService
NotCreatableService
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#
AllowInsertFreeModelsboolean | Indicates 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#
| ApproveAssetId | Deprecated. Accepts an asset ID for InsertService approval; calling it has no effect.Deprecated |
| ApproveAssetVersionId | Deprecated. Accepts an asset version ID for InsertService approval; calling it has no effect.Deprecated |
| CreateMeshPartAsync | Creates a new MeshPart with specified fidelity values.Yields |
| GetBaseCategories | DeprecatedYields |
| GetBaseSets | Returns an array of dictionaries, containing information about various Roblox approved sets.DeprecatedYields |
| GetCollection | Returns the most recently uploaded models in the specified category.DeprecatedYields |
| GetFreeDecals | Retrieves a list of free Decals from the Catalog.DeprecatedYields |
| GetFreeDecalsAsync | Retrieves a list of free Decals from the Catalog.Yields |
| GetFreeModels | Retrieves a list of Free Models from the Catalog.DeprecatedYields |
| GetFreeModelsAsync | Retrieves a list of Free Models from the Catalog.Yields |
| GetLatestAssetVersionAsync | 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.Yields |
| GetUserCategories | DeprecatedYields |
| GetUserSets | Returns an array of dictionaries, containing information about sets owned by the user.DeprecatedYields |
| Insert | Inserts Instance into Workspace.Deprecated |
| LoadAsset | Returns a Model containing the asset.Yields |
| loadAsset | DeprecatedYields |
| LoadAssetVersion | Returns 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.
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
assetVersionId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
meshId | ContentId | Mesh asset ID. | |
collisionFidelity | CollisionFidelity | Set MeshPart.CollisionFidelity. | |
renderFidelity | RenderFidelity | Set MeshPart.RenderFidelity. |
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.
| Name | Type | Default | Description |
|---|---|---|---|
categoryId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
searchText | string | String used to search for free decals in the Catalog. | |
pageNum | int | The 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:
[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.
| Name | Type | Default | Description |
|---|---|---|---|
searchText | string | String used to search for free decals in the Catalog. | |
pageNum | int | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
searchText | string | String used to search for free models in the Catalog. | |
pageNum | int | The 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:
[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.
| Name | Type | Default | Description |
|---|---|---|---|
searchText | string | String used to search for free decals in the Catalog. | |
pageNum | int | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
userId | User |
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. |
| Name | Type | Default | Description |
|---|---|---|---|
userId | User | The 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.
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:
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 pcall to 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:LoadAssetAsync()
and enable AssetService.AllowInsertFreeAssets.
See also:
AssetService:GetBundleDetailsAsync(), to find out which assets are associated with a bundle.- For plugins, see
DataModel:GetObjects()
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 |
Returns
LoadAssetVersion(assetVersionId: int64): Instance#
Yields
Returns a model inserted into InsertService containing the asset
with the given assetVersionId.
| Name | Type | Default | Description |
|---|---|---|---|
assetVersionId | int64 | The version ID of the asset to load. |
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild