Roblox UtilitiesDevlHub Roblox Documentation

Class

AssetService

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

A non-replicated service that handles asset-related queries to the Roblox web API.

AssetService is a non-replicated service that handles asset-related queries to the Roblox web API.

Properties 1#

AllowInsertFreeAssetsbooleanControls whether AssetService:LoadAssetAsync() can load assets that are not owned by the experience creator.Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe

AllowInsertFreeAssets: boolean#

Read: RobloxScriptSecurityWrite: RobloxScriptSecurityReadSafe

This property can only be modified in Studio's Experience Settings by changing Allow Loading Third Party Assets.

When false (default), AssetService:LoadAssetAsync() can only load assets that 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.

When true, AssetService:LoadAssetAsync() can additionally load any public free asset on the Creator Store.

Methods 25#

ComposeDecalAsyncModifies an existing Decal to contain a composite PBR textures created by layering the provided textures in the order they are provided in the layers array. Textures layer based on the alpha value of the color map.Yields
CreateAssetAsyncUploads a new asset to Roblox from the given object.Yields
CreateAssetVersionAsyncUploads a new version for an existing asset from the given object.Yields
CreateDataModelContentAsyncCreates ephemeral, DataModel-scoped content from the provided content input.Yields
CreateDecalAsyncCreates a new Decal object using the provided EditableImage content maps.Yields
CreateEditableImageCreates a new EditableImage.
CreateEditableImageAsyncCreates a new EditableImage object populated with the given image.Yields
CreateEditableMeshCreates a new, empty EditableMesh.
CreateEditableMeshAsyncReturns a new EditableMesh object created from an existing mesh content ID.Yields
CreateMeshPartAsyncCreates a new MeshPart with a specified mesh ID and an optional table of fidelity values.Yields
CreatePlaceAsyncClones a place through the given templatePlaceID.Yields
CreatePlaceInPlayerInventoryAsyncClones a place through the given templatePlaceID and puts it into the inventory of the given player.DeprecatedYields
CreateSurfaceAppearanceAsyncCreates a new SurfaceAppearance object using the provided content maps.Yields
GetAssetIdsForPackageReturns an array of asset IDs that are contained in a specified package.DeprecatedYields
GetAssetIdsForPackageAsyncReturns an array of asset IDs that are contained in a specified package.Yields
GetAudioMetadataAsyncProvides relevant metadata about a specific audio source.Yields
GetBundleDetailsAsyncReturns details of the contents of specified bundle.Yields
GetCreatorAssetIDReturns the UserId of the account who created the creationID asset.DeprecatedYields
GetGamePlacesAsyncReturns a StandardPages object which contains the name and PlaceId of places within the current experience.Yields
LoadAssetAsyncLoads a Model instance given its asset ID. This is the modern replacement for InsertService:LoadAsset() and supports loading third-party assets.Yields
PromptCreatePlatformContentAsyncAllows in-experience asset creation for users by prompting a publish dialog.Yields
PromptImportAnimationClipFromVideoAsyncPrompts the specified player to select and upload a video, which is then converted into an AnimationClip.Yields
SavePlaceAsyncSaves the state of the current place.Yields
SearchAudioFinds audio assets matching a variety of search criteria.DeprecatedYields
SearchAudioAsyncFinds audio assets matching a variety of search criteria.Yields

ComposeDecalAsync(decal: Decal, layers: Array): ()#

Yields

Modifies an existing Decal to contain a composed texture derived from one or more layered texture sets. Each set can include color, roughness, metalness, and normal maps. Each layer in layers is composited in the order they are provided, with the color map alpha channel used to determine blending.

  • There is a limit of 8 layers.
  • Layering order is bottom-to-top: the first layer in the list provides the bottom-most textures.
  • Each dictionary table should contain the following key-value pairs:
    • ColorMap: A Content referencing a color (albedo) texture by assetId.
    • RoughnessMap: A Content referencing a roughness texture by assetId.
    • MetalnessMap: A Content referencing a metalness texture by assetId.
    • NormalMap: A Content referencing a normal texture by assetId.
  • ColorMap is mandatory in every layer. The ColorMap's alpha channel is used to control blending of the entire layer.
  • NormalMap, MetalnessMap, RoughnessMap are optional. If omitted, this layer doesn't perform any blending for those maps.

Calling this method on a Decal that already has a pending ComposeDecalAsync call in progress raises an error; wait for the first call to resolve before issuing another on the same instance.

NameTypeDefaultDescription
decalDecalA Decal instance that will be modified to contain a representation of the layers. Any existing maps on this instance will be cleared.
layersArrayAn array of dictionary tables that maps PBR names to Content IDs.
Returns
  • ()

CreateAssetAsync(object: Object, assetType: AssetType, requestParameters: Dictionary = nil): Tuple#

Yields

Uploads a new asset to Roblox from the given object.

Currently, this method can only be used in locally loaded plugins and uploads assets without prompting first.

NameTypeDefaultDescription
objectObjectThe object to be created as an asset.
assetTypeAssetType

Currently supported types are:

requestParametersDictionarynil

Options table containing asset metadata:

  • Name – Name of the asset as a string. Defaults to [object.Name].
  • Description – Description of the asset as a string. Defaults to "Created with AssetService:CreateAssetAsync".
  • CreatorId – ID of the asset creator as a number. Defaults to the logged in Roblox Studio user for Plugin context. Required for Open Cloud Luau Execution context.
  • CreatorType – AssetCreatorType indicating the type of asset creator. Defaults to AssetCreatorType.User in Plugin context. Required for Open Cloud Luau Execution context.
  • IsPackage – Boolean value, only applicable to the AssetType.Model type. Defaults to true.
Returns

CreateAssetVersionAsync(object: Object, assetType: AssetType, assetId: int64, requestParameters: Dictionary = nil): Tuple#

Yields

Uploads a new version for an existing asset from the given object.

Currently, this method can only be used in locally loaded plugins and uploads assets without prompting first.

NameTypeDefaultDescription
objectObjectThe object to be created as an asset.
assetTypeAssetType

Currently supported types are:

assetIdint64The ID of the asset for the new version.
requestParametersDictionarynil

Options table containing asset metadata:

  • Name – A string. Name of the asset. Default: object.Name.
  • Description – A string. Description of the asset. Default: "Created with AssetService:CreateAssetAsync".
  • CreatorId – A number. ID of the asset creator. Default: The logged in Roblox Studio user for Plugin context. Required for Open Cloud Luau Execution context.
  • CreatorType – A AssetCreatorType. Type of asset creator. Default: AssetCreatorType.User in Plugin context. Required for Open Cloud Luau Execution context.
  • IsPackage – A bool. Only applicable to the AssetType.Model type. Default: true.
Returns

CreateDataModelContentAsync(content: Content, options: Dictionary?): Tuple#

Yields

Creates ephemeral, DataModel-scoped content from the provided content input.

If the server storage budget is exhausted during this call, the creation will fail and the method will return CreateContentResult.StorageLimitExceeded alongside an empty Content object.

NameTypeDefaultDescription
contentContentReference to the input content. Currently, this only supports Content wrapping a EditableMesh or EditableImage.
optionsDictionary?Optional dictionary containing configuration controls for the created DataModel content. Currently no controls are surfaced and this parameter exists for future functionality.
Returns

CreateDecalAsync(content: Dictionary): Decal#

Yields

Creates a new Decal object using the provided color and physically based rendering (PBR) content maps. Each supported key sets the corresponding Decal content property. All maps are optional individually, but at least one must be provided; a color texture is not required.

Use Content.fromObject() to wrap a EditableImage for each map. Asset IDs, URI-based content, and Content.none are not accepted. To use an image asset, first load it with AssetService:CreateEditableImageAsync(), then wrap the returned EditableImage with Content.fromObject().

Omitted maps remain unset. All other Decal properties retain their default values, and the returned decal has no parent. Set its Face and parent it to a BasePart to display it on the desired face.

Unrecognized keys are ignored with a warning. The method raises an error if no supported maps are provided, or if any supported key has a value that is not Content containing a EditableImage.

NameTypeDefaultDescription
contentDictionary

Dictionary containing one or more of the following key-value pairs. Each value must be a Content object containing a EditableImage:

  • TextureContent — The decal's color texture.
  • NormalMapContent — The decal's normal map.
  • MetalnessMapContent — The decal's metalness map.
  • RoughnessMapContent — The decal's roughness map.
Returns
  • Decal — A new Decal instance with the given maps from the content parameter.

CreateEditableImage(editableImageOptions: Dictionary?): EditableImage#

Creates a new EditableImage. By default, the resolution is set at 512×512, but you can specify a different size using the method's option table.

If the device‑specific editable memory budget is exhausted, creation fails and this method returns nil.

NameTypeDefaultDescription
editableImageOptionsDictionary?

Options table containing controls for the method:

  • Size – A Vector2 that specifies the image's desired width and height.
Returns

CreateEditableImageAsync(content: Content, editableImageOptions: Dictionary?): EditableImage#

Yields

Creates a new EditableImage object populated with the given texture. Non-asset texture IDs such as rbxthumb:// are supported. If using an image asset, it must be associated with and/or owned by a creator of the experience, or it must have been created inside the experience. If the device-specific editable memory budget is exhausted, creation will fail and this method will return nil.

See the EditableImage documentation for special considerations when using this API.

NameTypeDefaultDescription
contentContentReference to asset content stored externally or as an object within the place, wrapping a single value of one of the supported ContentSourceType values.
editableImageOptionsDictionary?Table containing options for the created EditableImage. Currently no options are available since resizing via Size is not supported.
Returns

CreateEditableMesh(editableMeshOptions: Dictionary?): EditableMesh#

Creates a new, empty EditableMesh. Vertices, triangles, and their attributes can be added dynamically to it. If the device‑specific editable memory budget is exhausted, creation will fail and this method will return nil.

NameTypeDefaultDescription
editableMeshOptionsDictionary?Table containing options for the created EditableMesh. Currently no options are available since FixedSize will always be false for empty editable meshes.
Returns

CreateEditableMeshAsync(content: Content, editableMeshOptions: Dictionary?): EditableMesh#

Yields

Returns a new EditableMesh object created from an existing EditableMesh or mesh Content ID. By default, an EditableMesh created from this method will be fixed size such that mesh data can only be modified, not added nor removed. A fixed size EditableMesh consumes less memory and should be preferred when possible.

If the device-specific editable memory budget is exhausted, creation will fail and this method will return nil.

See the Enabling for Published Experiences and Permissions sections of EditableMesh for special considerations when using this API.

NameTypeDefaultDescription
contentContentReference to asset content stored externally or as an object within the place, wrapping a single value of one of the supported ContentSourceType values.
editableMeshOptionsDictionary?

Options table containing controls for the method:

  • FixedSize – A bool. Default value is true, and the returned EditableMesh will not allow you to add or remove vertices, only modify their values. Set to false if the ability to change the mesh topology is required, at the expense of using more memory.
Returns

CreateMeshPartAsync(meshContent: Content, options: Dictionary = nil): MeshPart#

Yields

This method creates a MeshPart with a specified CollisionFidelity, RenderFidelity, and FluidFidelity. Because MeshPart.MeshId is read only, this method is for creating a mesh with any mesh ID through scripts, without having to clone an existing MeshPart. It throws errors if creation fails.

NameTypeDefaultDescription
meshContentContentReference to asset content stored externally or as an object within the place, wrapping a single value of one of the supported ContentSourceType values.
optionsDictionarynil

Options table containing one or more controls for the method:

Returns
  • MeshPart — The new MeshPart with the specified mesh and fidelity settings applied.

CreatePlaceAsync(placeName: string, templatePlaceID: int64, description: string): int64#

Yields

Clones a place through the given templatePlaceID and returns the PlaceId of the new place, which you can use with TeleportService. The clone place displays within the inventory of the place's creator with the given name and description.

Note that the template place must have template copying enabled through place settings. You cannot use this method to clone places that you don't own.

Frequent use of this API is not recommended, particularly if the created places contain scripts, as updating the code in a large volume of places quickly becomes infeasible. For user-generated worlds, consider serializing user creations and saving them in DataStores instead.

NameTypeDefaultDescription
placeNamestringName of the new place.
templatePlaceIDint64PlaceId of the place to clone.
descriptionstringDescription of the new place.
Returns
  • int64 — PlaceId of the new place.

CreatePlaceInPlayerInventoryAsync(player: Instance, placeName: string, templatePlaceID: int64, description: string): int64#

YieldsDeprecated

Deprecated. This method has been removed and is no longer functional.

This method was removed in release 471 and no longer functions; calling it raises an error. It previously cloned the place identified by templatePlaceID and placed the copy into the given player's inventory. There is no direct replacement.

NameTypeDefaultDescription
playerInstanceThe Player whose inventory receives the cloned place.
placeNamestringName for the new place.
templatePlaceIDint64PlaceId of the place to clone.
descriptionstringDescription for the new place.
Returns
  • int64 — PlaceId of the new place.

CreateSurfaceAppearanceAsync(content: Dictionary): SurfaceAppearance#

Yields

Creates a new SurfaceAppearance object using the provided content maps.

Currently, content only supports EditableImage and only content maps can be specified, but functionality will expand to include asset IDs as input. If you need to achieve this today, you can create an EditableImage from an asset ID using the following:

Class.AssetService:CreateEditableImageAsync(Content.fromUri(uri))

Default values will be used for all other SurfaceAppearance properties. Note that the EditableImage assigned to each map cannot be reassigned or swapped after the SurfaceAppearance is created.

NameTypeDefaultDescription
contentDictionary

Dictionary containing the following key-value pairs:

  • ColorMap — A Content object that contains the color map. Default is nil.
  • MetalnessMap — A Content object that contains the metalness map. If more than one channel is present, only the red channel is used. Default is nil.
  • NormalMap — A Content object that contains the normal map. Default is nil.
  • RoughnessMap — A Content object that contains the roughness map. If more than one channel is present, only the red channel is used. Default is nil.
  • EmissiveMask — A Content object that contains the emissive mask. If more than one channel is present, only the red channel is used. Default is nil.
Returns

GetAssetIdsForPackage(packageAssetId: int64): Array#

YieldsDeprecatedDeprecated

Deprecated. Use GetAssetIdsForPackageAsync() instead.

This deprecated method returns an array of asset IDs contained in the specified package. Use GetAssetIdsForPackageAsync() instead.

NameTypeDefaultDescription
packageAssetIdint64The asset ID of the package to query.
Returns
  • Array — Asset IDs that are contained in a specified package.

GetAssetIdsForPackageAsync(packageAssetId: int64): Array#

Yields

Returns an array of asset IDs that are contained in a specified package.

NameTypeDefaultDescription
packageAssetIdint64The asset ID of the package to query.
Returns
  • Array — Asset IDs that are contained in a specified package.

GetAudioMetadataAsync(idList: Array): Array#

Yields

Provides relevant metadata about a specific audio source (artist, title, duration, type, etc.).

NameTypeDefaultDescription
idListArrayArray of asset or content IDs for which to retrieve metadata. Max batch size is 30.
Returns
  • Array — Array of dictionary tables in the same order as the request, where each dictionary contains the following metadata for its asset/content:

    • AssetId (string)

    • Title (string)

    • Artist (string)

    • Duration (number) in seconds

    • AudioType (AudioSubType)

    Note that if an error occurs on fetching metadata for any of the requested assets, for example the asset ID doesn't exist, its dictionary table is still included in the returned array but it only contains the AssetId field for reference purposes. Additionally, if the AudioType cannot be determined for a given asset (perhaps because it's private audio), the resulting dictionary will not contain an AudioType entry.

GetBundleDetailsAsync(bundleId: int64): Dictionary#

Yields

This function returns details of the contents of the specified bundle.

If the bundle ID does not exist, it throws HTTP 400 (Bad Request). If bundleId is not convertible to an integer, it throws Unable to cast string to int64.

NameTypeDefaultDescription
bundleIdint64The ID of the specified bundle.
Returns
  • Dictionary —

    Dictionary with the following key-value pairs containing details about the specified bundle:

    • Id — Bundle ID (same as passed bundleId argument)

    • Name — Bundle name

    • Description — Bundle description

    • BundleType — String representing the BundleType, for example "BodyParts" or "DynamicHead"

    • Items — Array of items in the bundle, each with details represented through the following keys:

      • Id — Item ID

      • Name — Item name

      • Type — Item type such as "Asset"

      • AssetType — String representing the AvatarAssetType

      • SupportsHeadShapes — Whether the asset supports head shape swapping. Only present if AssetType is "DynamicHead".

GetCreatorAssetID(creationID: int64): int64#

YieldsDeprecatedDeprecated

Deprecated. This item is deprecated and no longer functions correctly. Do not use it for new work.

The GetCreatorAssetID function returns the Player.UserId of the account who created the creationID asset.

This member is broken and doesn't function correctly. Avoid using it.

NameTypeDefaultDescription
creationIDint64The asset ID to look up for creator information.
Returns
  • int64 — The Player.UserId of the account that created the asset.

GetGamePlacesAsync(): Instance#

Yields

Returns a StandardPages object which contains the name and PlaceId of places within the current experience.

Returns

LoadAssetAsync(assetId: int64): Instance#

Yields

Loads the latest version of an asset from the given assetId and returns it wrapped in a Model. This method is the modern replacement for InsertService:LoadAsset() and InsertService:LoadAssetVersion() methods.

Calls to this function may fail if the asset does not exist, or if the server providing the model is having problems. It is recommended to wrap calls to this function in pcall() to handle potential errors.

Luau
local AssetService = game:GetService("AssetService")

local assetId = 257489726

local success, model = pcall(AssetService.LoadAssetAsync, AssetService, assetId)
if success and model then
	print("Model loaded successfully")
	model.Parent = workspace
else
	warn("Model failed to load:", model) -- 'model' will contain the error message
end

Script Sandbox Security#

For enhanced security, the returned Model is sandboxed by default (Sandboxed is true) and has no script Capabilities. This prevents untrusted scripts descending from the returned Model from running. To enable scripts in a model you trust, you can manually grant a safe set of Capabilities on the Model after loading.

Third-Party Asset Loading#

Unlike InsertService:LoadAsset(), this method can load public assets created by third parties (assets not owned by the experience creator). To enable this functionality, toggle on Allow Loading Third Party Assets in Studio's Experience Settings.

If this setting is disabled (which it is by default), LoadAssetAsync will only load assets that are owned by the experience creator, behaving identically to the old InsertService:LoadAsset() security check.

NameTypeDefaultDescription
assetIdint64The asset ID number of the asset being loaded.
Returns

PromptCreatePlatformContentAsync(player: Player, object: Object, assetType: AssetType): Tuple#

Yields

Allows in-experience asset creation for users by prompting a publish dialog. When called, it presents a dialog to the user, allowing them to enter a name, description, and preview the asset. Upon submitting, it saves the asset to the user's inventory. Can only be invoked on the server side.

NameTypeDefaultDescription
playerPlayerThe user who submits an asset creation.
objectObjectThe asset to be created. Currently can't contain scripts or nest non-public assets.
assetTypeAssetTypeThe asset type. Currently can only be AssetType.Model.
Returns

PromptImportAnimationClipFromVideoAsync(player: Player, progressCallback: Function): Tuple#

Yields

Prompts the given player to select and upload a video on their own client, then converts the uploaded video into an AnimationClip and returns it. The player must grant consent through the prompt before the upload proceeds; if they decline or provide no input, the method resolves with AnimationClipFromVideoStatus.Cancelled and no clip.

This method can only be called from the server. The returned AnimationClipFromVideoStatus reports success or the reason processing failed.

NameTypeDefaultDescription
playerPlayerThe player who is prompted, on their own client, to select and upload a video. The player's consent is required before the video is uploaded.
progressCallbackFunctionA function that receives status updates (an AnimationClipFromVideoStatus value) while the video is uploaded and processed.
Returns

SavePlaceAsync(requestParameters: Dictionary?): ()#

Yields

Saves the current state of the place. Keep in mind the following guidelines and restrictions:

  • This method only works for places that are created with AssetService:CreatePlaceAsync() or that have the API enabled through the place's settings.
  • This method overwrites the previous state of the place. To revert a save, publish an older version of the place.
  • There are cases when saves can occur simultaneously in Studio and in multiple experience servers. The order of the saves happen in the order they are called.
  • An active Team Create session in Studio blocks all saves from occurring.
NameTypeDefaultDescription
requestParametersDictionary?Optional dictionary that includes SaveWithoutPublish, a boolean indicating whether to save with publish or without publish, and PlaceId, the destination place ID to save over. An example usage would be: AssetService:SavePlaceAsync({PlaceId = 1, SaveWithoutPublish = true}). If PlaceId is not provided, the default behavior will save over the current original place which is calling SavePlaceAsync. If SaveWithoutPublish is not provided, the default behavior is SaveWithoutPublish=false.
Returns
  • ()

SearchAudio(searchParameters: AudioSearchParams): AudioPages#

YieldsDeprecatedDeprecated

Deprecated. Use SearchAudioAsync() instead.

This deprecated method finds audio assets matching a variety of search criteria. Use SearchAudioAsync() instead.

NameTypeDefaultDescription
searchParametersAudioSearchParamsA AudioSearchParams object defining the search criteria such as keyword, title, artist, audio type, and duration range.
Returns

SearchAudioAsync(searchParameters: AudioSearchParams): AudioPages#

Yields

Returns a AudioPages object containing the result of the given search. Will not return fields with empty values.

Note that this method has a low HTTP request limit and can throw an error, so it should always be wrapped in pcall() for error handling. Possible error messages include:

Error Message Reason
HTTP 429 (Too Many Requests) Class.AssetService:SearchAudio() has been called too many times.
Unexpected type for data, expected array got null The keyword argument was filtered.
NameTypeDefaultDescription
searchParametersAudioSearchParamsA AudioSearchParams object defining the search criteria such as keyword, title, artist, audio type, and duration range.
Returns

Inherited members#

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

ClassName, className

Events (1)

Changed