Hi Creators,
As some of you may have seen, we rolled out the Accessory Adjustment tool to the Avatar Editor recently. We’ve seen really positive community feedback from the platform launch, and now we want to give you the ability to add this functionality to your experiences with the Accessory Adjustment API.
Accessory Adjustment in the platform Avatar Editor
You can implement Accessory Adjustment in your experiences using the new upgraded HumanoidDescription API. You can enable your users to alter position, rotation, and scale of Head and Face accessories on their avatars – both accessories they own and items they’re trying on before deciding to purchase.This opens up a new world of compatibility between different avatars and accompanying Head and Face accessories.
When the user owns the adjusted accessories, these adjustments can be saved back to the platform using AvatarEditorService:PromptSaveAvatar. Additionally, you can pair this with `PromptCreateOutfit’ to let the user save their full Avatar with adjustments back to the platform under Characters > Saved.
Here’s an example server script and local script you can try out yourself:
Server Script:
-- Accessory Adjustment server script
local Players = game:GetService("Players")
local userId = -1 -- replace with your userId
local playerModel = Players:CreateHumanoidModelFromUserId(userId)
playerModel.Parent = workspace
local humanoid = playerModel.Humanoid
local newHD = game.Players:GetHumanoidDescriptionFromUserId(userId)
local accessoryDescription = Instance.new("AccessoryDescription")
accessoryDescription.AssetId = 4819740796 -- add a hat that you own
accessoryDescription.AccessoryType = Enum.AccessoryType.Hat
accessoryDescription.Parent = newHD
playerModel.Humanoid:ApplyDescription(newHD)
for i, description in humanoid.HumanoidDescription:GetChildren() do
if description:IsA("AccessoryDescription") then
-- AccessoryDescriptions also help you get the Instance of the accessory, which will be helpful in adjustment
-- For example, we can show the user which accessory is selected by adorning a SelectionBox
local selectionBox = Instance.new("SelectionBox")
local accessoryInstance = description:GetAppliedInstance()
-- Adorn to the MeshPart Handle under the Accessory Instance
selectionBox.Adornee = accessoryInstance.Handle
selectionBox.Parent = workspace
-- setting the adjustments
description.Position = Vector3.new(0.2, 0.2, 0.2)
description.Rotation = Vector3.new(20, 20, 20)
description.Scale = Vector3.new(1.1, 1.1, 1.1)
end
end
local appliedDescription = humanoid.HumanoidDescription:Clone()
appliedDescription.Name = "AppliedDescription"
appliedDescription.Parent = workspace
Local Script:
-- Accessory Adjustment local script
local AvatarEditorService = game:GetService("AvatarEditorService")
-- get the appliedDescription made from our server script
local appliedDescription = workspace:WaitForChild("AppliedDescription")
-- save the avatar with the adjustments
AvatarEditorService:PromptSaveAvatar(appliedDescription, Enum.HumanoidRigType.R15)
--same with PromptCreateOutfit to create outfits
--AvatarEditorService:PromptCreateOutfit(appliedDescription, Enum.HumanoidRigType.R15)
Please Note: To keep the platform safe, we are only allowing Face and Head accessory adjustments at this time. In the future, we will be expanding the types of accessories, specifically Neck/Shoulder and then Front/Back. Some accessory categories will have a limited ability to be adjusted to ensure avatars are appropriate for the Roblox.
To access the currently allowed AssetTypes and adjustment limits of each accessory type, the Avatar Rules have been updated:
local AvatarEditorService = game:GetService("AvatarEditorService")
local avatarRules = AvatarEditorService:GetAvatarRules()
–- AccessoryRefinementTypes is a list of the allowed AssetType values
print(avatarRules.AccessoryRefinementTypes)
–- AccessoryRefinementUpperBounds is a table of the allowed upper adjustment limits for each accessory type
print(avatarRules.AccessoryRefinementUpperBounds)
–- AccessoryRefinementUpperBounds is a table of the allowed lower adjustment limits for each accessory type
print(avatarRules.AccessoryRefinementLowerBounds)
AccessoryRefinementUpperBounds
and AccessoryRefinementLowerBounds
allow you to check that your experience doesn’t apply an adjustment that can’t be saved to the platform. Trying to save values out of the bounds will clamp the values during saving.
Special thanks to the team that helped make this happen: @JollySunbro6, @Peaze4ly, @gcheck14552, @Nimniteshyamalan, @LoboTheCzarnian, @legendRf20, @SergeantBlocky, @misterpebblez, @Padi_Xiaokeai, @pbloxi, @Vvhere2021, @FarazTheGreat, & @timetopretend8.
Please let us know if you have any questions. We can’t wait to see what you build with the Accessory Adjustment APIs in Avatar Editor experiences!
Happy creating!