Skip to content

Service · inherits Instance

AssetService

Official docs ↗

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 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.

    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.

  • 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.StorageLimitExceeded alongside an empty Content object.

  • CreateDecalAsync(content: Dictionary) → DecalYieldsCreates a new Decal object using the provided EditableImage content maps.

    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.

  • CreateEditableImage(editableImageOptions: Dictionary?) → EditableImageCreates a new 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.

  • CreateEditableImageAsync(content: Content, editableImageOptions: Dictionary?) → EditableImageYieldsCreates a new EditableImage object populated with the given image.

    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.

  • CreateEditableMesh(editableMeshOptions: Dictionary?) → EditableMeshCreates a new, empty 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.

  • CreateEditableMeshAsync(content: Content, editableMeshOptions: Dictionary?) → EditableMeshYieldsReturns a new EditableMesh object created from an existing mesh content ID.

    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.

  • CreateMeshPartAsync(meshContent: Content, options: Dictionary = nil) → MeshPartYieldsCreates a new MeshPart with a specified mesh ID and an optional table of fidelity values.

    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.

  • CreatePlaceAsync(placeName: string, templatePlaceID: int64, description: string) → int64YieldsClones a place through the given templatePlaceID.

    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.

  • CreateSurfaceAppearanceAsync(content: Dictionary) → SurfaceAppearanceYieldsCreates a new SurfaceAppearance object using the provided content maps.

    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.

  • 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). If bundleId is not convertible to an integer, it throws Unable to cast string to int64.

  • GetGamePlacesAsync() → InstanceYieldsReturns a StandardPages object which contains the name and PlaceId of places within the current experience.
  • LoadAssetAsync(assetId: int64) → InstanceYieldsLoads a Model instance given its asset ID. This is the modern replacement for InsertService.LoadAsset and supports loading third-party assets.

    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
    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.

  • 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 an AnimationClip.

    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.

  • 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.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.
  • SearchAudioAsync(searchParameters: AudioSearchParams) → AudioPagesYieldsFinds audio assets matching a variety of search criteria.

    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:

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.