Service · inherits Instance
AssetService
A non-replicated service that handles asset-related queries to the Roblox web API.
About AssetService
AssetService is a non-replicated service that handles asset-related queries to the Roblox web API.
Methods 21
ComposeDecalAsync
(decal: Decal, layers: Array) → ()YieldsModifies an existingDecalto contain a composite PBR textures created by layering the provided textures in the order they are provided in thelayersarray. Textures layer based on the alpha value of the color map.Modifies an existing
Decalto contain a composed texture derived from one or more layered texture sets. Each set can include color, roughness, metalness, and normal maps. Each layer inlayersis 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
Decalthat already has a pendingComposeDecalAsynccall in progress raises an error; wait for the first call to resolve before issuing another on the same instance.CreateAssetAsync
(object: Object, assetType: AssetType, requestParameters: Dictionary = nil) → TupleYieldsUploads a new asset to Roblox from the given object.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.
CreateAssetVersionAsync
(object: Object, assetType: AssetType, assetId: int64, requestParameters: Dictionary = nil) → TupleYieldsUploads a new version for an existing asset from the given object.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.
CreateDataModelContentAsync
(content: Content, options: Dictionary?) → TupleYieldsCreates ephemeral,DataModel-scoped content from the provided content input.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.StorageLimitExceededalongside an emptyContentobject.CreateDecalAsync
(content: Dictionary) → DecalYieldsCreates a newDecalobject using the providedEditableImagecontent maps.Creates a new
Decalobject using the provided color and physically based rendering (PBR) content maps. Each supported key sets the correspondingDecalcontent property. All maps are optional individually, but at least one must be provided; a color texture is not required.Use
Content.fromObjectto wrap aEditableImagefor each map. Asset IDs, URI-based content, andContent.noneare not accepted. To use an image asset, first load it withAssetService.CreateEditableImageAsync, then wrap the returnedEditableImagewithContent.fromObject.Omitted maps remain unset. All other
Decalproperties retain their default values, and the returned decal has no parent. Set itsFaceand parent it to aBasePartto 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
Contentcontaining aEditableImage.CreateEditableImage
(editableImageOptions: Dictionary?) → EditableImageCreates a newEditableImage.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.CreateEditableImageAsync
(content: Content, editableImageOptions: Dictionary?) → EditableImageYieldsCreates a newEditableImageobject populated with the given image.Creates a new
EditableImageobject populated with the given texture. Non-asset texture IDs such asrbxthumb://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 returnnil.See the
EditableImagedocumentation for special considerations when using this API.CreateEditableMesh
(editableMeshOptions: Dictionary?) → EditableMeshCreates a new, emptyEditableMesh.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 returnnil.CreateEditableMeshAsync
(content: Content, editableMeshOptions: Dictionary?) → EditableMeshYieldsReturns a newEditableMeshobject created from an existing mesh content ID.Returns a new
EditableMeshobject created from an existingEditableMeshor meshContentID. By default, anEditableMeshcreated from this method will be fixed size such that mesh data can only be modified, not added nor removed. A fixed sizeEditableMeshconsumes 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
EditableMeshfor special considerations when using this API.CreateMeshPartAsync
(meshContent: Content, options: Dictionary = nil) → MeshPartYieldsCreates a newMeshPartwith a specified mesh ID and an optional table of fidelity values.This method creates a
MeshPartwith a specifiedCollisionFidelity,RenderFidelity, andFluidFidelity. BecauseMeshPart.MeshIdis read only, this method is for creating a mesh with any mesh ID through scripts, without having to clone an existingMeshPart. It throws errors if creation fails.CreatePlaceAsync
(placeName: string, templatePlaceID: int64, description: string) → int64YieldsClones a place through the giventemplatePlaceID.Clones a place through the given
templatePlaceIDand returns thePlaceIdof the new place, which you can use withTeleportService. 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
DataStoresinstead.CreateSurfaceAppearanceAsync
(content: Dictionary) → SurfaceAppearanceYieldsCreates a newSurfaceAppearanceobject using the provided content maps.Creates a new
SurfaceAppearanceobject using the provided content maps.Currently, content only supports
EditableImageand 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 anEditableImagefrom an asset ID using the following:Class.AssetService:CreateEditableImageAsync(Content.fromUri(uri))Default values will be used for all other
SurfaceAppearanceproperties. Note that theEditableImageassigned to each map cannot be reassigned or swapped after theSurfaceAppearanceis created.GetAssetIdsForPackageAsync
(packageAssetId: int64) → ArrayYieldsReturns an array of asset IDs that are contained in a specified package.GetAudioMetadataAsync
(idList: Array) → ArrayYieldsProvides relevant metadata about a specific audio source.Provides relevant metadata about a specific audio source (artist, title, duration, type, etc.).
GetBundleDetailsAsync
(bundleId: int64) → DictionaryYieldsReturns details of the contents of specified bundle.This function returns details of the contents of the specified bundle.
If the bundle ID does not exist, it throws
HTTP 400 (Bad Request). IfbundleIdis not convertible to an integer, it throwsUnable to cast string to int64.GetGamePlacesAsync
() → InstanceYieldsReturns aStandardPagesobject which contains the name andPlaceIdof places within the current experience.LoadAssetAsync
(assetId: int64) → InstanceYieldsLoads aModelinstance given its asset ID. This is the modern replacement forInsertService.LoadAssetand supports loading third-party assets.Loads the latest version of an asset from the given
assetIdand returns it wrapped in aModel. This method is the modern replacement forInsertService.LoadAssetandInsertService.LoadAssetVersionmethods.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
Modelis sandboxed by default (Sandboxedistrue) and has no scriptCapabilities. 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 ofCapabilitieson 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),
LoadAssetAsyncwill only load assets that are owned by the experience creator, behaving identically to the oldInsertService.LoadAssetsecurity check.PromptCreatePlatformContentAsync
(player: Player, object: Object, assetType: AssetType) → TupleYieldsAllows in-experience asset creation for users by prompting a publish dialog.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.
PromptImportAnimationClipFromVideoAsync
(player: Player, progressCallback: Function) → TupleYieldsPrompts the specified player to select and upload a video, which is then converted into anAnimationClip.Prompts the given
playerto select and upload a video on their own client, then converts the uploaded video into anAnimationClipand returns it. The player must grant consent through the prompt before the upload proceeds; if they decline or provide no input, the method resolves withAnimationClipFromVideoStatus.Cancelledand no clip.This method can only be called from the server. The returned
AnimationClipFromVideoStatusreports success or the reason processing failed.SavePlaceAsync
(requestParameters: Dictionary?) → ()YieldsSaves the state of the current place.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.CreatePlaceAsyncor 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.
- This method only works for places that are created with
SearchAudioAsync
(searchParameters: AudioSearchParams) → AudioPagesYieldsFinds audio assets matching a variety of search criteria.Returns a
AudioPagesobject 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:
AssetService 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.