AssetService
The AssetService is a non-replicated service that handles asset related queries to the Roblox web API. Eventually, this will house all asset related queries for Roblox objects stored in the web. One should mind the limitations this API has.
Summary
Properties
Methods
Creates a new EditableImage instance populated with the given image.
Returns a new EditableMesh instance created from an existing mesh content ID.
Returns a new EditableMesh instance created from an existing MeshPart.
Clones a place with placeId equal to given templatePlaceId.
Clones a place which has placeId equal to given templatePlaceId and puts it into the inventory of the given player.
Returns an array of assetIds that are contained in a specified package.
Returns a StandardPages object which contains the name and placeId of places within the current 'Game' (otherwise known as a 'Universe').
Allows in-experience asset creation for users by prompting a publish dialog when they press the submit button.
Finds audio assets matching a variety of search criteria.
Events
Properties
Methods
CreateEditableImageAsync
Creates a new EditableImage instance 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.
Parameters
Texture ID of the image to populate the EditableImage.
Returns
A new EditableImage containing the provided image.
CreateEditableMeshAsync
Returns a new EditableMesh instance created from an existing mesh content ID.
Parameters
Content ID of the mesh from which to create an EditableMesh instance.
Returns
The new EditableMesh instance.
CreateEditableMeshFromPartAsync
Returns a new EditableMesh instance created from the MeshId of an existing MeshPart.
Parameters
The MeshPart from which to create an EditableMesh instance. The part must have a valid MeshId for this method to operate.
Returns
The new EditableMesh instance.
CreatePlaceAsync
Clones a place with placeId equal to given templatePlaceId. The clone place displays within the inventory of the place's creator with the given name and description. This method returns the placeId of the new place, which you can use with TeleportService. 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 isn't 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.
Parameters
Returns
CreatePlaceInPlayerInventoryAsync
This function has been removed as of Release 471. Clones a place which has a placeId equal to the given templatePlaceID, placing it into the inventory of the given player with the given name and description, if they accept when prompted. This method cannot be used to clone places that you do not own, or those which have disabled the use of the CreatePlace API in their place's configuration.
Parameters
Returns
GetAssetIdsForPackage
Returns an array of assetIds that are contained in a specified package.
Parameters
Returns
GetBundleDetailsAsync
If the bundle ID does not exist, it throws HTTP 400 (HTTP/1.1 400 Bad Request). If bundleId is not convertible to int, throws "Unable to cast string to int64". If param type is string, it implicitly tries to convert to int.
This function returns details of the contents of the specified bundle.
Understanding the returned ValueTable
It returns a ValueTable object with the following key-value pairs containing details about the specified bundle
Key Name | Value Type | Description |
---|---|---|
Id number | int | Bundle ID (passed in as an argument) |
Name | string | Bundle name |
Description | string | Bundle description |
BundleType | string | Bundle Type. eg. BodyParts or AvatarAnimation|AvatarAnimations |
Items | ValueArray | An array of ValueTable objects |
Each object in the Items array contains details of the item as described in the table below:
Key Name | Value Type | Description |
---|---|---|
Id number | int | Item's id |
Name | string | Item name |
Type | string | Item Type eg: "UserOutfit" or "Asset" |
Parameters
The id of the specified bundle.
Returns
A ValueTable object with the following key-value pairs containing details about the specified bundle. See the function description for more information.
Code Samples
local AssetService = game:GetService("AssetService")
local BUNDLE_ID = 13
local bundleDetails = AssetService:GetBundleDetailsAsync(BUNDLE_ID)
print(bundleDetails)
GetGamePlacesAsync
Returns a StandardPages object which contains the name and placeId of places within the current 'Game' (otherwise known as a 'Universe').
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local pages = AssetService:GetGamePlacesAsync()
while true do
for _, place in pairs(pages:GetCurrentPage()) do
print("Name: " .. place.Name)
print("PlaceId: " .. tostring(place.PlaceId))
end
if pages.IsFinished then
-- we reached the last page of results
break
end
pages:AdvanceToNextPageAsync()
end
PromptCreateAssetAsync
Allows in-experience asset creation for users by prompting a publish dialog when they press the submit button. Can only be invoked on the server side. When called, it presents a dialog to the user. The dialog allows users to enter a name, description, and preview the asset. Upon submitting, it saves the asset to the user's inventory.
Parameters
Represents the user who submits an asset creation.
Represents the asset to be created. Currently can't contain scripts or nest non-public assets.
The asset type. Currently can only be AssetType.Model.
Returns
The PromptCreateAssetResult and asset ID pair if successful.
PromptImportAnimationClipFromVideoAsync
Parameters
Returns
SavePlaceAsync
Saves the state of the current place. This only works for places that are created with AssetService:CreatePlaceAsync() or have the API enabled through place settings.
Returns
SearchAudio
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) | AssetService:SearchAudio() has been called too many times. |
Unexpected type for data, expected array got void | The keyword argument was filtered. |
Parameters
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local audioSearchParams = Instance.new("AudioSearchParams")
audioSearchParams.SearchKeyword = "happy"
local success, result = pcall(function()
return AssetService:SearchAudio(audioSearchParams)
end)
if success then
local currentPage = result:GetCurrentPage()
for _, audio in currentPage do
print(audio.Title)
end
else
warn("AssetService error: " .. result)
end
--[[ Returned data format
{
"AudioType": string,
"Artist": string,
"Title": string,
"Tags": {
"string"
},
"Id": number,
"IsEndorsed": boolean,
"Description": string,
"Duration": number,
"CreateTime": string,
"UpdateTime": string,
"Creator": {
"Id": number,
"Name": string,
"Type": number,
"IsVerifiedCreator": boolean
}
}
--]]