Engine Class
AvatarCreationService
Summary
Methods
Events
AvatarAssetModerationCompleted(assetId: number,moderationStatus: Enum.ModerationStatus):RBXScriptSignal |
AvatarModerationCompleted(outfitId: number,moderationStatus: Enum.ModerationStatus):RBXScriptSignal |
API Reference
Methods
AutoSetupAvatarAsync
AvatarCreationService:AutoSetupAvatarAsync(
Parameters
Returns
Code Samples
AutoSetupAvatarAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LoadAvatarEvent = ReplicatedStorage.LoadAvatarEvent
local generatedAvatars = {}
-- Must be called on the server
local function setupAvatar(player: Player, avatarModel: Model, layeredShirtModel : Model)
local arguments = {
Body = avatarModel,
Accessories = {}
}
local accessoryArgument = {
AccessoryType = Enum.AccessoryType.Shirt,
IsLayered = true,
Instance = layeredShirtModel,
}
table.insert(arguments.Accessories, accessoryArgument)
local pcallSuccess, result = pcall(function()
local generationId = AvatarCreationService:AutoSetupAvatarAsync(
player,
arguments,
function(progressInfo)
print(`AutoSetup progress: {progressInfo.Progress * 100}%`)
end
)
-- Load and store on the server to use with PromptCreateAvatarAsync
local humanoidDescription = AvatarCreationService:LoadGeneratedAvatarAsync(generationId)
generatedAvatars[generationId] = humanoidDescription
-- Signal the client so it can load the avatar for local preview
LoadAvatarEvent:FireClient(player, generationId)
end)
if not pcallSuccess then
warn("Avatar setup failed:", result)
end
endGenerateAvatar2DPreviewAsync
AvatarCreationService:GenerateAvatar2DPreviewAsync(
Parameters
Returns
GenerateAvatarAsync
AvatarCreationService:GenerateAvatarAsync(
Parameters
Returns
GetBatchTokenDetailsAsync
LoadAvatar2DPreviewAsync
Parameters
Returns
LoadGeneratedAvatarAsync
Parameters
Returns
Code Samples
LoadGeneratedAvatarAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
local Players = game:GetService("Players")
-- Can be called on either the server or client
local function loadAvatar(generationId: string): Model?
local pcallSuccess, result = pcall(function()
local humanoidDescription = AvatarCreationService:LoadGeneratedAvatarAsync(generationId)
local model = Players:CreateHumanoidModelFromDescriptionAsync(humanoidDescription, Enum.HumanoidRigType.R15)
return model
end)
if pcallSuccess then
return result
else
print("Avatar failed to load:", result)
return nil
end
endPrepareAvatarForPreviewAsync
PromptCreateAvatarAssetAsync
AvatarCreationService:PromptCreateAvatarAssetAsync(
Parameters
Returns
Code Samples
PromptCreateAvatarAssetAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
local function publishAvatarAsset(tokenId: string, player: Player, assetInstance: Accessory, assetType: Enum.AvatarAssetType)
local pcallSuccess, result, resultMessage = pcall(function()
return AvatarCreationService:PromptCreateAvatarAssetAsync(tokenId, player, assetInstance, assetType)
end)
if pcallSuccess then
if result == Enum.PromptCreateAssetResult.Success then
print("Successfully uploaded with AssetId: ", resultMessage)
else
print("Unsuccessfully uploaded with error message:", resultMessage)
end
else
print("Avatar asset failed to create.")
end
endPromptCreateAvatarAsync
AvatarCreationService:PromptCreateAvatarAsync(
Parameters
Returns
Code Samples
PromptCreateAvatarAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
export type BodyPartInfo = {
bodyPart: Enum.BodyPart,
instance: Instance, --Folder with Created MeshParts
}
export type BodyPartList = { BodyPartInfo }
local function publishAvatar(bodyPartInstances: BodyPartList, player: Player, tokenId: string)
local humanoidDescription = Instance.new("HumanoidDescription")
for _, bodyPartInfo in bodyPartInstances do
local bodyPartDescription = Instance.new("BodyPartDescription")
bodyPartDescription.Instance = bodyPartInfo.instance
bodyPartDescription.BodyPart = bodyPartInfo.bodyPart
bodyPartDescription.Parent = humanoidDescription
end
local pcallSuccess, result, resultMessage = pcall(function()
return AvatarCreationService:PromptCreateAvatarAsync(tokenId, player, humanoidDescription)
end)
if pcallSuccess then
if result == Enum.PromptCreateAvatarResult.Success then
print("Successfully uploaded with BundleId: ", resultMessage)
else
print("Unsuccessfully uploaded with error message:", resultMessage)
end
else
print("Avatar failed to create.")
end
endPromptSelectAvatarGenerationImageAsync
RequestAvatarGenerationSessionAsync
ValidateUGCAccessoryAsync
AvatarCreationService:ValidateUGCAccessoryAsync(
Parameters
Returns
ValidateUGCBodyPartAsync
AvatarCreationService:ValidateUGCBodyPartAsync(
Parameters
Returns
ValidateUGCFullBodyAsync
AvatarCreationService:ValidateUGCFullBodyAsync(
Parameters
Returns
Events
AvatarAssetModerationCompleted
AvatarCreationService.AvatarAssetModerationCompleted(
Parameters
Code Samples
Avatar Asset Moderation Completed
local AvatarCreationService = game:GetService("AvatarCreationService")
local conn = AvatarCreationService.AvatarAssetModerationCompleted:Connect(function(assetId, moderationStatus)
print("Asset, " .. assetId .. ", ready with moderation status: " .. moderationStatus)
end)AvatarModerationCompleted
AvatarCreationService.AvatarModerationCompleted(
Parameters