เรียนรู้
Engine Class
AvatarCreationService
ไม่สามารถสร้าง
บริการ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
AutoSetupAvatarAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:AutoSetupAvatarAsync(
player:Player, autoSetupParams:Dictionary, progressCallback:function?
พารามิเตอร์
player:Player
autoSetupParams:Dictionary
progressCallback:function?
ส่งค่ากลับ
ตัวอย่างโค้ด
AutoSetupAvatarAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LoadAvatarEvent = ReplicatedStorage.LoadAvatarEvent
local generatedAvatars = {}
-- ต้องเรียกในเซิร์ฟเวอร์
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
)
-- โหลดและเก็บไว้บนเซิร์ฟเวอร์เพื่อนำไปใช้กับ PromptCreateAvatarAsync
local humanoidDescription = AvatarCreationService:LoadGeneratedAvatarAsync(generationId)
generatedAvatars[generationId] = humanoidDescription
-- ส่งสัญญาณไปยังลูกค้าเพื่อให้สามารถโหลด avatar สำหรับการแสดงตัวอย่างในพื้นที่
LoadAvatarEvent:FireClient(player, generationId)
end)
if not pcallSuccess then
warn("การตั้งค่า avatar ล้มเหลว:", result)
end
end

GenerateAvatar2DPreviewAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:GenerateAvatar2DPreviewAsync(
avatarGeneration2dPreviewParams:Dictionary, progressCallback:function?
พารามิเตอร์
avatarGeneration2dPreviewParams:Dictionary
progressCallback:function?
ส่งค่ากลับ

GenerateAvatarAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:GenerateAvatarAsync(
avatarGenerationParams:Dictionary, progressCallback:function?
พารามิเตอร์
avatarGenerationParams:Dictionary
progressCallback:function?
ส่งค่ากลับ

GetBatchTokenDetailsAsync
ผลตอบแทน
ความสามารถ: Monetization
AvatarCreationService:GetBatchTokenDetailsAsync(tokenIds:{any}):{any}
พารามิเตอร์
tokenIds:{any}
ส่งค่ากลับ

GetValidationRules
AvatarCreationService:GetValidationRules():Dictionary
ส่งค่ากลับ

LoadAvatar2DPreviewAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:LoadAvatar2DPreviewAsync(previewId:string):EditableImage
พารามิเตอร์
previewId:string
ส่งค่ากลับ

LoadGeneratedAvatarAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:LoadGeneratedAvatarAsync(generationId:string):HumanoidDescription
พารามิเตอร์
generationId:string
ส่งค่ากลับ
ตัวอย่างโค้ด
โหลดอวาตาร์ที่สร้างขึ้นแบบอะซิงโครนัส
local AvatarCreationService = game:GetService("AvatarCreationService")
local Players = game:GetService("Players")
-- สามารถเรียกใช้ได้ทั้งบนเซิร์ฟเวอร์หรือไคลเอนต์
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 ได้:", result)
return nil
end
end

PrepareAvatarForPreviewAsync
ผลตอบแทน
ความสามารถ: AvatarAppearance
AvatarCreationService:PrepareAvatarForPreviewAsync(humanoidModel:Model):()
พารามิเตอร์
humanoidModel:Model
ส่งค่ากลับ
()

PromptCreateAvatarAssetAsync
ผลตอบแทน
AvatarCreationService:PromptCreateAvatarAssetAsync(
tokenId:string, player:Player, assetInstance:Instance, assetType:Enum.AvatarAssetType
พารามิเตอร์
tokenId:string
player:Player
assetInstance:Instance
ส่งค่ากลับ
ตัวอย่างโค้ด
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("อัปโหลดสำเร็จด้วย AssetId: ", resultMessage)
else
print("อัปโหลดไม่สำเร็จด้วยข้อความแสดงข้อผิดพลาด:", resultMessage)
end
else
print("ไม่สามารถสร้างทรัพย์สินอวาตาร์ได้.")
end
end

PromptCreateAvatarAsync
ผลตอบแทน
ความสามารถ: AssetCreateUpdate, Monetization
AvatarCreationService:PromptCreateAvatarAsync(
tokenId:string, player:Player, humanoidDescription:HumanoidDescription
พารามิเตอร์
tokenId:string
player:Player
humanoidDescription:HumanoidDescription
ส่งค่ากลับ
ตัวอย่างโค้ด
PromptCreateAvatarAsync
local AvatarCreationService = game:GetService("AvatarCreationService")
export type BodyPartInfo = {
bodyPart: Enum.BodyPart,
instance: Instance, --โฟลเดอร์ที่มี 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("อัปโหลดสำเร็จพร้อมกับ BundleId: ", resultMessage)
else
print("อัปโหลดไม่สำเร็จพร้อมกับข้อความแสดงข้อผิดพลาด:", resultMessage)
end
else
print("การสร้างอวตาร์ล้มเหลว.")
end
end

PromptSelectAvatarGenerationImageAsync
ผลตอบแทน
ความสามารถ: SensitiveInput
AvatarCreationService:PromptSelectAvatarGenerationImageAsync(player:Player):string
พารามิเตอร์
player:Player
ส่งค่ากลับ

RequestAvatarGenerationSessionAsync
ผลตอบแทน
ความสามารถ: DynamicGeneration
AvatarCreationService:RequestAvatarGenerationSessionAsync(
player:Player, callback:function
พารามิเตอร์
player:Player
callback:function
ส่งค่ากลับ

ValidateUGCAccessoryAsync
ผลตอบแทน
AvatarCreationService:ValidateUGCAccessoryAsync(
player:Player, accessory:Instance, accessoryType:Enum.AccessoryType
พารามิเตอร์
player:Player
accessory:Instance
accessoryType:Enum.AccessoryType
ส่งค่ากลับ

ValidateUGCBodyPartAsync
ผลตอบแทน
AvatarCreationService:ValidateUGCBodyPartAsync(
player:Player, instance:Instance, bodyPart:Enum.BodyPart
พารามิเตอร์
player:Player
instance:Instance
bodyPart:Enum.BodyPart
ส่งค่ากลับ

ValidateUGCFullBodyAsync
ผลตอบแทน
AvatarCreationService:ValidateUGCFullBodyAsync(
player:Player, humanoidDescription:HumanoidDescription
พารามิเตอร์
player:Player
humanoidDescription:HumanoidDescription
ส่งค่ากลับ

เหตุการณ์
AvatarAssetModerationCompleted
ความสามารถ: DynamicGeneration
AvatarCreationService.AvatarAssetModerationCompleted(
assetId:number, moderationStatus:Enum.ModerationStatus
พารามิเตอร์
assetId:number
moderationStatus:Enum.ModerationStatus
ตัวอย่างโค้ด
local AvatarCreationService = game:GetService("AvatarCreationService")
local conn = AvatarCreationService.AvatarAssetModerationCompleted:Connect(function(assetId, moderationStatus)
print("สินทรัพย์, " .. assetId .. ", พร้อมกับสถานะการตรวจสอบ: " .. moderationStatus)
end)

AvatarModerationCompleted
ความสามารถ: DynamicGeneration
AvatarCreationService.AvatarModerationCompleted(
outfitId:number, moderationStatus:Enum.ModerationStatus
พารามิเตอร์
outfitId:number
moderationStatus:Enum.ModerationStatus

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ