Class
AssetService
NotCreatableService
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#
AllowInsertFreeAssetsboolean | Controls 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#
| ComposeDecalAsync | Modifies 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 |
| CreateAssetAsync | Uploads a new asset to Roblox from the given object.Yields |
| CreateAssetVersionAsync | Uploads a new version for an existing asset from the given object.Yields |
| CreateDataModelContentAsync | Creates ephemeral, DataModel-scoped content from the provided
content input.Yields |
| CreateDecalAsync | Creates a new Decal object using the provided
EditableImage content maps.Yields |
| CreateEditableImage | Creates a new EditableImage. |
| CreateEditableImageAsync | Creates a new EditableImage object populated with the given image.Yields |
| CreateEditableMesh | Creates a new, empty EditableMesh. |
| CreateEditableMeshAsync | Returns a new EditableMesh object created from an existing mesh
content ID.Yields |
| CreateMeshPartAsync | Creates a new MeshPart with a specified mesh ID and an optional
table of fidelity values.Yields |
| CreatePlaceAsync | Clones a place through the given templatePlaceID.Yields |
| CreatePlaceInPlayerInventoryAsync | Clones a place through the given templatePlaceID and puts it into the
inventory of the given player.DeprecatedYields |
| CreateSurfaceAppearanceAsync | Creates a new SurfaceAppearance object using the provided content
maps.Yields |
| GetAssetIdsForPackage | Returns an array of asset IDs that are contained in a specified package.DeprecatedYields |
| GetAssetIdsForPackageAsync | Returns an array of asset IDs that are contained in a specified package.Yields |
| GetAudioMetadataAsync | Provides relevant metadata about a specific audio source.Yields |
| GetBundleDetailsAsync | Returns details of the contents of specified bundle.Yields |
| GetCreatorAssetID | Returns the UserId of the account who created the creationID asset.DeprecatedYields |
| GetGamePlacesAsync | Returns a StandardPages object which contains the name and
PlaceId of places within the current experience.Yields |
| LoadAssetAsync | Loads a Model instance given its asset ID. This is the modern
replacement for InsertService:LoadAsset() and supports loading
third-party assets.Yields |
| PromptCreatePlatformContentAsync | Allows in-experience asset creation for users by prompting a publish dialog.Yields |
| PromptImportAnimationClipFromVideoAsync | Prompts the specified player to select and upload a video, which is then
converted into an AnimationClip.Yields |
| SavePlaceAsync | Saves the state of the current place.Yields |
| SearchAudio | Finds audio assets matching a variety of search criteria.DeprecatedYields |
| SearchAudioAsync | Finds 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:
ColorMapis mandatory in every layer. The ColorMap's alpha channel is used to control blending of the entire layer.NormalMap,MetalnessMap,RoughnessMapare 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.
| Name | Type | Default | Description |
|---|---|---|---|
decal | Decal | A Decal instance that will be modified to contain a
representation of the layers. Any existing maps on this instance will
be cleared. | |
layers | Array | An 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.
| Name | Type | Default | Description |
|---|---|---|---|
object | Object | The object to be created as an asset. | |
assetType | AssetType | Currently supported types are:
| |
requestParameters | Dictionary | nil | Options table containing asset metadata:
|
Returns
Tuple— TheCreateAssetResultand asset ID pair if successful.
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.
| Name | Type | Default | Description |
|---|---|---|---|
object | Object | The object to be created as an asset. | |
assetType | AssetType | Currently supported types are:
| |
assetId | int64 | The ID of the asset for the new version. | |
requestParameters | Dictionary | nil | Options table containing asset metadata:
|
Returns
Tuple— TheCreateAssetResultand asset version number pair if successful.
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.
| Name | Type | Default | Description |
|---|---|---|---|
content | Content | Reference to the input content. Currently, this only supports
Content wrapping a EditableMesh or
EditableImage. | |
options | Dictionary? | Optional dictionary containing configuration controls for the created
DataModel content. Currently no controls are surfaced and this
parameter exists for future functionality. |
Returns
Tuple— A tuple containing anCreateContentResultindicating the success or failure of the request, and the resultingDataModel-scopedOpaqueContent.
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.
| Name | Type | Default | Description |
|---|---|---|---|
content | Dictionary | Dictionary containing one or more of the following key-value pairs.
Each value must be a
|
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.
| Name | Type | Default | Description |
|---|---|---|---|
editableImageOptions | Dictionary? | Options table containing controls for the method:
|
Returns
EditableImage— The newEditableImage, ornilif the device-specific editable memory budget is exhausted.
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.
| Name | Type | Default | Description |
|---|---|---|---|
content | Content | Reference to asset content stored externally or as an object within
the place, wrapping a single value of one of the supported
ContentSourceType values. | |
editableImageOptions | Dictionary? | Table containing options for the created EditableImage.
Currently no options are available since resizing via
Size is not supported. |
Returns
EditableImage— A newEditableImagecontaining the provided image.
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.
| Name | Type | Default | Description |
|---|---|---|---|
editableMeshOptions | Dictionary? | Table containing options for the created EditableMesh.
Currently no options are available since
FixedSize will always be false for
empty editable meshes. |
Returns
EditableMesh— The newEditableMesh, ornilif the device-specific editable memory budget is exhausted.
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.
| Name | Type | Default | Description |
|---|---|---|---|
content | Content | Reference to asset content stored externally or as an object within
the place, wrapping a single value of one of the supported
ContentSourceType values. | |
editableMeshOptions | Dictionary? | Options table containing controls for the method:
|
Returns
EditableMesh— The newEditableMeshobject.
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.
| Name | Type | Default | Description |
|---|---|---|---|
meshContent | Content | Reference to asset content stored externally or as an object within
the place, wrapping a single value of one of the supported
ContentSourceType values. | |
options | Dictionary | nil | Options table containing one or more controls for the method:
|
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.
| Name | Type | Default | Description |
|---|---|---|---|
placeName | string | Name of the new place. | |
templatePlaceID | int64 | PlaceId of the place to clone. | |
description | string | Description of the new place. |
Returns
int64—PlaceIdof 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.
| Name | Type | Default | Description |
|---|---|---|---|
player | Instance | The Player whose inventory receives the cloned place. | |
placeName | string | Name for the new place. | |
templatePlaceID | int64 | PlaceId of the place to clone. | |
description | string | Description for the new place. |
Returns
int64—PlaceIdof 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.
| Name | Type | Default | Description |
|---|---|---|---|
content | Dictionary | Dictionary containing the following key-value pairs:
|
Returns
SurfaceAppearance— A newSurfaceAppearanceinstance with the given maps from thecontentparameter.
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.
| Name | Type | Default | Description |
|---|---|---|---|
packageAssetId | int64 | The 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.
| Name | Type | Default | Description |
|---|---|---|---|
packageAssetId | int64 | The 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.).
| Name | Type | Default | Description |
|---|---|---|---|
idList | Array | Array 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 secondsAudioType(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
AssetIdfield for reference purposes. Additionally, if theAudioTypecannot be determined for a given asset (perhaps because it's private audio), the resulting dictionary will not contain anAudioTypeentry.
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.
| Name | Type | Default | Description |
|---|---|---|---|
bundleId | int64 | The 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 passedbundleIdargument)Name— Bundle nameDescription— Bundle descriptionBundleType— String representing theBundleType, for example"BodyParts"or"DynamicHead"Items— Array of items in the bundle, each with details represented through the following keys:Id— Item IDName— Item nameType— Item type such as"Asset"AssetType— String representing theAvatarAssetTypeSupportsHeadShapes— Whether the asset supports head shape swapping. Only present ifAssetTypeis"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.
| Name | Type | Default | Description |
|---|---|---|---|
creationID | int64 | The asset ID to look up for creator information. |
Returns
int64— ThePlayer.UserIdof 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
Instance— AStandardPagesobject whose pages contain the name andPlaceIdof each place in the current experience.
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.
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
endScript 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.
| Name | Type | Default | Description |
|---|---|---|---|
assetId | int64 | The asset ID number of the asset being loaded. |
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.
| Name | Type | Default | Description |
|---|---|---|---|
player | Player | The user who submits an asset creation. | |
object | Object | The asset to be created. Currently can't contain scripts or nest non-public assets. | |
assetType | AssetType | The asset type. Currently can only be AssetType.Model. |
Returns
Tuple— ThePromptCreatePlatformContentResultand asset ID pair if successful.
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.
| Name | Type | Default | Description |
|---|---|---|---|
player | Player | The 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. | |
progressCallback | Function | A function that receives status updates (an
AnimationClipFromVideoStatus value) while the video is uploaded
and processed. |
Returns
Tuple— A tuple containing anAnimationClipFromVideoStatusdescribing the outcome and, on success, the resultingAnimationClip(nilotherwise).
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.
| Name | Type | Default | Description |
|---|---|---|---|
requestParameters | Dictionary? | 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.
| Name | Type | Default | Description |
|---|---|---|---|
searchParameters | AudioSearchParams | A AudioSearchParams object defining the search criteria such
as keyword, title, artist, audio type, and duration range. |
Returns
AudioPages— AnAudioPagesobject containing the paginated results of the audio search.
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. |
| Name | Type | Default | Description |
|---|---|---|---|
searchParameters | AudioSearchParams | A AudioSearchParams object defining the search criteria such
as keyword, title, artist, audio type, and duration range. |
Returns
AudioPages— AnAudioPagesobject containing the paginated results of the audio search.
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