This upgraded API was announced to be “fully backwards compatible with the old HumanoidDescription APIs” so my game shouldn’t be affected by these changes.
This happened because during the rollout of the new HumanoidDescription API, there was a circumstance when publishing from a team create game to another place caused duplicate AccessoryDescriptions or BodyPartDescriptions to be created. We have now enabled this feature for studio and this duplication should no longer be happening but it won’t fix games where it has already occurred. To fix games where it has already occurred, you can close and reopen studio to make sure you have the feature enabled and then run the following script:
local LOCATIONS_TO_PROCESS = {
game:GetService("Workspace"),
game:GetService("ReplicatedStorage"),
game:GetService("ServerStorage"),
game:GetService("ServerScriptService"),
game:GetService("StarterGui"),
game:GetService("ReplicatedFirst"),
game:GetService("StarterPack"),
game:GetService("StarterPlayer"),
game:GetService("Lighting"),
}
local totalDuplicatesRemoved = 0
local function deduplicateSubDescriptions(humanoidDescription, className, getKeyFunction)
local seenKeys = {}
local childrenToRemove = {}
for _, child in humanoidDescription:GetChildren() do
if child:IsA(className) then
local key = getKeyFunction(child)
if seenKeys[key] then
table.insert(childrenToRemove, child)
else
seenKeys[key] = true
end
end
end
for _, child in childrenToRemove do
child:Destroy()
totalDuplicatesRemoved = totalDuplicatesRemoved + 1
end
end
local function processChildrenRecursive(instance)
if instance:IsA("HumanoidDescription") then
deduplicateSubDescriptions(instance, "AccessoryDescription", function(accessoryDescription)
return accessoryDescription.AssetId
end)
deduplicateSubDescriptions(instance, "BodyPartDescription", function(bodyPartDescription)
return bodyPartDescription.BodyPart
end)
return
end
for _, child in instance:GetChildren() do
processChildrenRecursive(child)
end
end
for _, location in LOCATIONS_TO_PROCESS do
processChildrenRecursive(location)
end
print("Total duplicate AccessoryDescriptions and BodyPartDescriptions removed:", totalDuplicatesRemoved)
After running the code above, it seems to have a bug where it clears other BodyPartDescription’s that are required. This only occurred for the “Noob” character which doesn’t have any accessories. I think this is due to the default bodyparts for a character having an assetid of 0.
This is a good point, I have updated my script to deduplicate BodyPartDescriptions by BodyPart instead of by AssetId. I have edited my post above in case anyone else needs this.