Service · inherits Instance
AvatarCreationService
A service to support developer avatar creators.
About AvatarCreationService
AvatarCreationService is a service that supports developer avatar creators,
providing methods that support the prompting of avatar creation from within
experiences.
Methods 16
AutoSetupAvatarAsync
(player: Player, autoSetupParams: Dictionary, progressCallback: Function?) → stringYieldsAutomatically sets up a customModeland/or avatar accessories.Automatically sets up a custom
Modelas an avatar asset. This method returns astringgeneration ID which can be passed toLoadGeneratedAvatarAsync()to load the generated avatar and return aHumanoidDescriptionwith all the generated instances and properties. The load method can be called on both the server and client, allowing the generated avatar to be loaded in both places (on the client for previewing, and on the server for saving the generated avatar to the player's inventory usingPromptCreateAvatarAsync()).Auto-setup has specific model requirements and accepts certain configurations of models. For more information, see Auto-setup requirements.
Note: this API requires the
Enable Mesh / Image APIssetting to be turned on under Content Settings for your experience.GenerateAvatar2DPreviewAsync
(avatarGeneration2dPreviewParams: Dictionary, progressCallback: Function?) → stringYieldsCreates a 2D avatar preview and returns apreviewId.Creates a 2D avatar image preview, taking as input the FileId from
PromptSelectAvatarGenerationImageAsync()and an optional text prompt. It returns apreviewIdwhich can be passed toLoadAvatar2DPreviewAsync()to retrieve the preview image on the client. This API can only be used on the game server.Note: this API requires the
Enable Mesh / Image APIssetting to be turned on under Content Settings for your experience.GenerateAvatarAsync
(avatarGenerationParams: Dictionary, progressCallback: Function?) → stringYieldsGenerates an avatar and returns a generationId.Generate an avatar from a preview and return the generationId. The
LoadGeneratedAvatarAsync()method is then called to retrieve the generatedHumanoidDescriptionavatar. This API can only be used on the game server.Note: this API requires the
Enable Mesh / Image APIssetting to be turned on under Content Settings for your experience.GetBatchTokenDetailsAsync
(tokenIds: Array) → ArrayYieldsGets the avatar creation token details for a list of avatar creation tokens at once.Gets the avatar creation token details for a list of avatar creation tokens at once (tokens are generated through the token creation process). Returns an array of avatar creation token details; each token detail is a dictionary with the fields indicated in the example result below:
{ ["Name"] = "string", ["Description"] = "string", ["UniverseId"] = 0, ["CreatorId"] = 0, ["CreatorType"] = Enum.CreatorType.User, ["OnSale"] = true, ["Price"] = 0, ["OffSaleReasons"] = { "string", } }GetValidationRules
() → DictionaryGets data regarding rules that assets must abide by to pass UGC validation.Gets data regarding rules that assets must abide by to pass UGC validation. Validation is an essential step before creating avatars and there are various checks that occur, including mesh triangle limits, texture sizes, body part size limits, attachment positions, and more.
The returned dictionary of validation rules takes the following form:
{ ["MeshRules"] = { ["BodyPartMaxTriangles"] = { Enum.AssetType.DynamicHead: number, Enum.AssetType.LeftArm: number, Enum.AssetType.RightArm: number, Enum.AssetType.Torso: number, Enum.AssetType.LeftLeg: number, Enum.AssetType.RightLeg: number, }, ["AccessoryMaxTriangles"]: number, ["MeshVertColor"]: Color3, ["CageMeshMaxDistanceFromRenderMesh"]: number, }, ["TextureRules"] = { ["MaxTextureSize"]: number, }, ["BodyPartRules"] = { [Enum.AssetType.DynamicHead] = { ["Bounds"] = { ["Classic"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, ["ProportionsSlender"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, ["ProportionsNormal"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, }, ["SubParts"] = { ["Head"] = { ["NeckRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["FaceFrontAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["HatAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["HairAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["FaceCenterAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, }, }, }, [Enum.AssetType.LeftArm] = { ["Bounds"] = { ["Classic"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, ["ProportionsSlender"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, ["ProportionsNormal"] = { ["MinSize"]: Vector3, ["MaxSize"]: Vector3, }, }, ["SubParts"] = { ["LeftHand"] = { ["LeftWristRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["LeftGripAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, }, ["LeftUpperArm"] = { ["LeftShoulderRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["LeftShoulderAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["LeftElbowRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, }, ["LeftLowerArm"] = { ["LeftElbowRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, ["LeftWristRigAttachment"] = { ["LowerBound"]: Vector3, ["UpperBound"]: Vector3, }, }, }, }, ... }, ["AccessoryRules"] = { [Enum.AssetType.HairAccessory] = { ["Attachments"] = { { ["Size"]: Vector3, ["Offset"]: Vector3, ["Name"]: string, }, }, ["RigidAllowed"]: boolean, }, ... }, ["MakeupRules"] = { ["ReferenceCageMeshId"]: number, ["WrapTextureTransferUVBounds"] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, ["ExcludeUVBounds"] = { [Enum.AssetType.FaceMakeup] = { ["LeftEye"] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, ["RightEye"] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, ["Lips"] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, }, }, ["IncludeUVBounds"] = { [Enum.AssetType.LipMakeup] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, [Enum.AssetType.EyeMakeup] = { ["MinBound"]: Vector2, ["MaxBound"]: Vector2, }, } } }LoadAvatar2DPreviewAsync
(previewId: string) → EditableImageYieldsLoad an AvatarGeneration 2D preview on the client from a previewId.Load an AvatarGeneration 2D preview as an
EditableImageon the client for the given previewId. This API can only be used on the client.Note: this API requires the
Enable Mesh / Image APIssetting to be turned on under Content Settings for your experience.LoadGeneratedAvatarAsync
(generationId: string) → HumanoidDescriptionYieldsLoads a generated avatar using an avatar generation ID.Loads a generated avatar using an avatar generation ID, as returned by
AutoSetupAvatarAsync()orGenerateAvatarAsync(). The generated avatar will be returned as aHumanoidDescriptionwith all the generated instances and properties. Mesh and texture assets will be provided asEditableMeshandEditableImageobjects, respectively, to allow continued editing of the generated avatar.This method can be called on both the server and client, allowing the generated avatar to be loaded in both places (on the client for previewing, and on the server for saving the generated avatar to the player's inventory using
PromptCreateAvatarAsync()). Once the method has been invoked on both the client and server, the data associated with the generation ID will be erased and subsequent calls to his method with the same generation ID will fail.Note: this API requires the
Enable Mesh / Image APIssetting to be turned on under Content Settings for your experience.PrepareAvatarForPreviewAsync
(humanoidModel: Model) → ()YieldsPrepares in-experience avatar for preview.Triggers HSR generation and attachment point updating for in-experience avatar previews. This allows for previewing of avatars created in experience with layered clothing and accessories in the same way they will appear when published through
PromptCreateAvatarAsync().When developers use
EditableMeshandWrapDeformerto modify avatars before publishing, the original HSR data may not accurately account for the new deformations. This method generates updated HSR data and corrects attachment points based on theWrapDeformermodifications, ensuring consistent preview and published avatar appearance.PromptCreateAvatarAssetAsync
(tokenId: string, player: Player, assetInstance: Instance, assetType: AvatarAssetType) → TupleYieldsPrompts aPlayerto purchase and create an avatar asset from anInstance.Prompts a
Playerto purchase and create an avatar asset from anInstance. The price of the creation is dictated by the price attributed to the avatar creation token. This creation token is required for the purchasing and creation of the asset and can be generated by following the token creation process.For accessory creation, the
Instanceis expected to include a new accessory to be created. This includes the following types:Hat,Hair,FaceAccessory,NeckAccessory,ShoulderAccessory,FrontAccessory,BackAccessory,WaistAccessory,TShirtAccessory,ShirtAccessory,PantsAccessory,JacketAccessory,SweaterAccessory,ShortsAccessory,DressSkirtAccessory,EyebrowAccessory, andEyelashAccessory.To support this, the
Instanceshould be anAccessoryinstance or contain anAccessorychild instance. This should include aMeshPartchild instance which makes up the accessory.The avatar asset
MeshPartwill also need to include:- An
EditableImage. - An
EditableMesh.
If creating a layered clothing accessory such as a shirt, the
MeshPartshould include aWrapDeformerwith anEditableMesh.This method also supports
FaceMakeup,LipMakeup, andEyeMakeup. For these types,assetInstancemust be aDecalwhoseDecal.TextureContentreferences anEditableImage, with exactly oneWrapTextureTransferchild. The accessory and MeshPart requirements above do not apply to these types.Finally, the provided
AvatarAssetTypeshould match the creation type of the token and the type of asset for upload.- An
PromptCreateAvatarAsync
(tokenId: string, player: Player, humanoidDescription: HumanoidDescription) → TupleYieldsPrompts aPlayerto purchase and create an avatar from aHumanoidDescription.Prompts a
Playerto purchase and create an avatar from aHumanoidDescription. The price of the creation is dictated by the price attributed to the avatar creation token. This avatar creation token is required for the purchasing and creation of the body and can be generated by following the token creation process.For avatar creation, the
HumanoidDescriptionis expected to include new assets to be created for each of the 6 body parts (Head,Torso,RightLeg,LeftLeg,RightArm,LeftArm). Optionally, it can also include a newHairaccessory.To support this, the
HumanoidDescriptionshould include 6BodyPartDescriptionchildren (one for each body part). For each, theBodyPartDescription.Instanceproperty references aFolderwhich includes all of theMeshPartinstances which make up the body part, for example aLeftArmfolder which hasLeftHand,LeftUpperArm, andLeftLowerArmMeshParts. TheBodyPartDescription.BodyPartproperty should also be set to the relevantBodyPart.Each body part
MeshPartwill also need to include:- An
EditableImage. - A
WrapDeformerwith anEditableMesh.
If including an accessory such as hair, the
HumanoidDescriptionshould include a childAccessoryDescriptionwhere:- The
AccessoryDescription.Instanceproperty references theAccessoryinstance. - The
AccessoryDescription.AccessoryTypeproperty is set to the relevantAccessoryType.
Finally, the
HumanoidDescriptionshould include the humanoid scales ofBodyTypeScale,HeadScale,HeightScale,WidthScale, andProportionScale. Be mindful of the scales that a base body is imported with so that they match the scales provided to theHumanoidDescription.- An
PromptCreateMakeupAsync
(player: Player, makeupAssetEntries: Array, thumbnailHeadColor: Color3? = nil) → TupleYieldsPrompts aPlayerto create and publish a makeup look from multiple makeup assets.Prompts a
Playerto create and publish a makeup look from two to six makeup assets. For example, an in-experience creation tool can use this method to let a player publish lip and face makeup together as a single look. This method can only be called from the server and yields until the operation completes.Each asset requires a creation token for its asset type and the current experience. See the token creation process. The input entries are checked before the prompt opens. Creation token and user-generated content validation run while the prompt is loading; the player can proceed with creation after validation succeeds.
For
FaceMakeup,LipMakeup, andEyeMakeup, the asset instance must be aDecalwhoseDecal.TextureContentreferences anEditableImage, with exactly oneWrapTextureTransferchild.The overall
PromptCreateOutfitResultdescribes creation of the look:Successmeans all submitted assets and the makeup look were created.PartialSuccessmeans at least one asset was created, but another asset or the makeup look composition failed. If the look was created, the second return value is its outfit ID; if composition failed, it is an error message instead.CreationFailuremeans no assets were created, so no makeup look was created.
Inspect the per-asset results to determine which assets were created. Each entry contains
Successand an asset ID, orUploadFailedwithout an asset ID. If a failure occurs before asset uploads, the results array may be empty.For
PermissionDenied,Timeout, andNoUserInput, only the result enum is returned; variables assigned to the other return values receivenil.This method can raise an error for invalid input, request throttling, or unexpected failures. Validation failures may raise an error or return
UGCValidationFailedwith an error message and an empty per-asset results array. Usepcall()to handle errors as well as checking the returned result enum.PromptSelectAvatarGenerationImageAsync
(player: Player) → stringYieldsPrompt thePlayerto take a selfie and return the FileId.Prompt the
Playerto take a selfie and return the FileId of the selfie. This FileId is then passed as an argument toGenerateAvatar2DPreviewAsync(). This API can only be used on the game server.local AvatarCreationService = game:GetService("AvatarCreationService") function promptSelectAvatarGenerationImage(player) local pcallSuccess, result = pcall(function() return AvatarCreationService:PromptSelectAvatarGenerationImageAsync(player) end) if not pcallSuccess then errName, errDesc = unpack(string.split(result, ": ")) if errName == "SelfieConsentDenied" then warn("Player must accept consent to use feature.") else warn("Failed to prompt for image: ", errDesc) end end return result endOn failure, the result string has the format
ErrorName: Error description, allowing the error type to be identified programmatically.RequestAvatarGenerationSessionAsync
(player: Player, callback: Function) → TupleYieldsRequest an AvatarGeneration session for aPlayer.Request an AvatarGeneration session for a
Player. Information about the session is returned via the callback, including the SessionId which is passed to theGenerateAvatar2DPreviewAsync()andGenerateAvatarAsync()methods. Additional session information includes allowed 2d preview generations, allowed 3d avatar generations, and the session time. The method returns aTuplewith anRBXScriptConnectionand estimatedwaitTime. TheRBXScriptConnectionallows canceling a session request. The estimatedwaitTimeis used to provide the player an estimated time in seconds until the session will be ready. This API can only be used on the game server.ValidateUGCAccessoryAsync
(player: Player, accessory: Instance, accessoryType: AccessoryType) → TupleYieldsStudio only. Runs UGC validation for anAccessoryType.Studio only. Given a
PlayerandInstancefor anAccessoryType, determines if UGC validation passes.ValidateUGCBodyPartAsync
(player: Player, instance: Instance, bodyPart: BodyPart) → TupleYieldsStudio only. Runs UGC validation for anBodyPart.Studio only. Given a
PlayerandInstancefor anBodyPart, determines if UGC validation passes. Theinstanceparameter is expected as aFolderin the following example format with relevantMeshParts:LeftArm(Folder)
However, if the expected
bodyPartisBodyPart.Head, the function takes a singularHeadMeshPartdirectly.ValidateUGCFullBodyAsync
(player: Player, humanoidDescription: HumanoidDescription) → TupleYieldsStudio only. Runs UGC validation for a whole body.Studio only. Given a
PlayerandHumanoidDescription, all instances in theHumanoidDescriptionwill be validated.The
HumanoidDescriptionis expected to include instances set onBodyPartDescriptionchildren for each of the six requiredBodyPartvalues. Optionally, it can include instances set onAccessoryDescriptionchildren for any supportedAccessoryType.
Events 2
AvatarAssetModerationCompleted
AvatarCreationService.AvatarAssetModerationCompleted:Connect(function(assetId, moderationStatus))Fires when an in-experience-created avatar asset's moderation status has been updated from pending.Fires when an in-experience-created avatar asset's moderation status has been updated from pending. This event provides a streamlined way to know when an avatar asset created through
PromptCreateAvatarAssetAsync()has completed the moderation process and is ready for use in-experience.Note that this event only fires for avatar assets created within the current experience and will trigger when the
ModerationStatuschanges fromNotReviewedto any other status. The event fires on the client only.AvatarOutfitModerationCompleted
AvatarCreationService.AvatarOutfitModerationCompleted:Connect(function(outfitId, moderationStatus, outfitType))Fires on the client when moderation completes for an in-experience-created outfit.Fires on the client when an in-experience-created outfit's moderation status changes from
NotReviewedto another status. Use this event for any in-experience-created outfit type. Current outfit creation flows includePromptCreateAvatarAsync(). Future in-experience outfit types will use this event as well (AvatarModerationCompletedis deprecated).Use
outfitTypeto determine the kind of outfit that completed moderation. This event is informational: an outfit cannot be used until its moderation status permits it.
AvatarCreationService 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.