AssetService
AssetService is a non-replicated service that handles asset-related queries to the Roblox web API.
Summary
Methods
Uploads a new asset to Roblox from the given object.
- CreateAssetVersionAsync(object : Object,assetType : Enum.AssetType,assetId : number,requestParameters : Dictionary):Tuple
Uploads a new version for an existing asset from the given object.
Creates a new EditableImage.
Creates a new EditableImage object populated with the given image.
Creates a new, empty EditableMesh.
Returns a new EditableMesh object created from an existing mesh content ID.
Creates a new MeshPart with a specified mesh ID and an optional table of fidelity values.
Clones a place through the given templatePlaceID.
- CreatePlaceInPlayerInventoryAsync(player : Instance,placeName : string,templatePlaceID : number,description : string):number
Clones a place through the given templatePlaceID and puts it into the inventory of the given player.
Returns an array of asset IDs that are contained in a specified package.
Provides relevant metadata about a specific audio source.
Returns details of the contents of specified bundle.
Returns a StandardPages object which contains the name and PlaceId of places within the current experience.
Allows in-experience asset creation for users by prompting a publish dialog.
Saves the state of the current place.
Finds audio assets matching a variety of search criteria.
Properties
Methods
CreateAssetAsync
Parameters
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local editableMesh = AssetService:CreateEditableMesh()
-- add vertices, faces, and uvs to the mesh
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
Name = "My asset",
Description = "a good asset",
}
local ok, result, idOrUploadErr = pcall(function()
return AssetService:CreateAssetAsync(editableMesh, Enum.AssetType.Mesh, requestParameters)
end)
if not ok then
warn(`error calling CreateAssetAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`success, new asset ID: {idOrUploadErr}`)
else
warn(`upload error in CreateAssetAsync: {result}, {idOrUploadErr}`)
end
CreateAssetVersionAsync
Parameters
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local assetIdToUpdate = 321
local model = Instance.new("Model")
local requestParameters = {
CreatorId = 123,
CreatorType = Enum.AssetCreatorType.User,
}
local ok, result, versionOrUploadErr = pcall(function()
return AssetService:CreateAssetVersionAsync(model, Enum.AssetType.Model, assetIdToUpdate, requestParameters)
end)
if not ok then
warn(`error calling CreateAssetVersionAsync: {result}`)
elseif result == Enum.CreateAssetResult.Success then
print(`success, new asset version: {versionOrUploadErr}`)
else
warn(`upload error in CreateAssetVersionAsync: {result}, {versionOrUploadErr}`)
end
CreateEditableImageAsync
Parameters
Returns
CreateEditableMeshAsync
Parameters
Returns
CreateMeshPartAsync
Parameters
Returns
CreatePlaceAsync
Parameters
Returns
CreatePlaceInPlayerInventoryAsync
Parameters
Returns
GetAudioMetadataAsync
Parameters
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local SoundService = game:GetService("SoundService")
local trackIDs = {
SoundService.Sound1.SoundId,
SoundService.Sound2.SoundId,
SoundService.Sound3.SoundId,
SoundService.Sound4.SoundId,
}
local success, result = pcall(function()
return AssetService:GetAudioMetadataAsync(trackIDs)
end)
if success then
for i = 1, #trackIDs do
local contentId = "rbxassetid://" .. result[i].AssetId
if trackIDs[i] == contentId then
print(result[i].Title, "by", result[i].Artist)
else
warn("No metadata fetched for requested asset #" .. tostring(i))
end
end
end
GetBundleDetailsAsync
Parameters
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local BUNDLE_ID = 14
local success, result = pcall(function()
return AssetService:GetBundleDetailsAsync(BUNDLE_ID)
end)
if success then
print(result)
--[[
{
["BundleType"] = "BodyParts",
["Description"] = "The year is 5003, Battlebot 5000 must face his mightiest foe, or face becoming obsolete.",
["Id"] = 14,
["Items"] = {
[1] = {...},
[2] = {
["Id"] = 1678225030,
["Name"] = "SinisterBot 5001 Left Arm",
["Type"] = "Asset"
},
[3] = {...},
[4] = {...},
[5] = {...},
[6] = {...},
[7] = {...}
},
["Name"] = "SinisterBot 5001"
}
--]]
end
GetGamePlacesAsync
Returns
Code Samples
local AssetService = game:GetService("AssetService")
local placePages = AssetService:GetGamePlacesAsync()
while true do
for _, place in placePages:GetCurrentPage() do
print("Name:", place.Name)
print("PlaceId:", place.PlaceId)
end
if placePages.IsFinished then
break
end
placePages:AdvanceToNextPageAsync()
end
PromptCreateAssetAsync
Parameters
Returns
PromptImportAnimationClipFromVideoAsync
Parameters
Returns
SavePlaceAsync
Returns
SearchAudio
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
}
}
--]]