I could not look for any solution of this anywhere on the devforum. Title is self explanatory.
As @austtm linked, the docs are a good place to look.
You’ll find that there’s properties for all the different accessories. You should be able to write a script that applies only the accessories from there.
i looked at the documentation and made this as a result.
local description = players:GetHumanoidDescriptionFromUserId(player.UserId)
local newdescription = humanoid:GetAppliedDescription()
newdescription:SetAccessories(description:GetAccessories(),true)
humanoid:ApplyDescription(newdescription)
i got this error.
10:31:20.069 Argument 1 missing or nil - Server - customavatars:16
Which line in the code excerpt you provided is line 16?
While @austtm Mentioned where is the line 16, Instead of applying description for ONLY accessories, i got you a better option.
AddAccessory.
This method is in the HUMANOID class. This is much simpler than apply the description.
Unless you really want and need the apply description, this is a great way.
There are a few ways. Also, wait briefly after the character loads before calling GetHumanoidDescriptionFromUserId to avoid nil.
function applyAccessories(char, desc)
local newDesc = Instance.new("HumanoidDescription")
newDesc.HatAccessory = desc.HatAccessory
newDesc.HairAccessory = desc.HairAccessory
newDesc.FaceAccessory = desc.FaceAccessory
newDesc.NeckAccessory = desc.NeckAccessory
newDesc.ShoulderAccessory = desc.ShoulderAccessory
newDesc.FrontAccessory = desc.FrontAccessory
newDesc.BackAccessory = desc.BackAccessory
newDesc.WaistAccessory = desc.WaistAccessory
char:FindFirstChildOfClass("Humanoid"):ApplyDescription(newDesc)
end
local desc = Players:GetHumanoidDescriptionFromUserId(userId)
applyAccessories(character, desc)
the setaccessories section is line 16.
A few things to try:
- Ensure that GetAppliedDescription is actually returning the correct HumanoidDescription.
- Add a short task.wait() after GetAppliedDescription before calling GetAccessories to give the HumanoidDescription time to load.
- If all else fails, try @2112Jay’s method above.