Humanoid Description not applying dynamic head

Hey developers!
I’ve been trying to make a dynamic character builder for my game using HumanoidDescriptions and other stuff, but for some reason Dynamic Heads never load…

Here’s the code:

local RStorage = game:GetService("ReplicatedStorage")
local InsertService = game:GetService("InsertService")

local CosmeticsData = require(RStorage.Databases.CosmeticsData)

-- To avoid pasting all 200 lines of code, just know that self.Wearing looks like this:
self.Wearing = {
	Accessories = {1,2},
	Bodyparts = {1,2},
	Clothing = {}
}

function NPC:BuildChar()
	
	local Char = script["BaseRig"..self.RigType]:Clone()
	
	-- Loading Accessories (IGNORE THIS PART)
	for _, id in self.Wearing.Accessories do
		local acc = CosmeticsData.Accessories[id]
		if not acc then warn("Could not find accessory with ID "..id); continue end
		
		local Model = nil
		
		if typeof(acc.ID) == "number" then
			Model = InsertService:LoadAsset(acc.ID):GetChildren()[1]
		else
			Model = RStorage.Assets.Accessories:FindFirstChild(acc.ID)
		end
		
		if Model == nil then continue end
		Model.Parent = Char
	end
	
	-- Loading Bodyparts (THIS IS WHAT DOESN'T WORK)
	local desc = Char.Humanoid.HumanoidDescription:Clone()
	
	for _, id in self.Wearing.Bodyparts do
		local acc = CosmeticsData.Bodyparts[id]
		if not acc then warn("Could not find accessory with ID "..id); continue end
		
		if typeof(acc.ID) == "number" then
			desc[acc.Type] = acc.ID
		end
		
	end
	
	Char.Parent = workspace
	Char.Humanoid:ApplyDescription(desc)
	Char.Parent = game.ServerStorage
	
	return Char
	
end

And this is the CosmeticsData script:

local Data = {
	Accessories = {
		{Name = "Sunglasses", Type = "Face", ID = 14400254687},	-- ID1
		{Name = "Tophat", Type = "Head", ID = "Tophat1"},		-- ID2
	},
	Bodyparts = {
		{Name = "testArm", Type = "LeftArm", ID = 27493648},	-- ID1
		{Name = "testHead", Type = "Head", ID = 3264},			-- ID2
	},
	Clothing = {}
}

return Data

Finally, here’s the base rig (left) and the end result (right):

As you can see, the face remains the same, but everything else loads in just fine…
Does anyone know what might be the problem?

1 Like

Hi, sincere apologies for this bump but I was trying to solve this issue myself and found a solution that ended up working for me that I believe will also work for you!

I was trying to load a dynamic head via humanoid description onto a rig, however doing so would never load the head. What I discovered is that a rig and a player character have a very different structure, which could probably be why it wasn’t working.

Here’s my rig hierarchy:

And then here is my player hierarchy:

Long story short, I got a rig to apply the dynamic head by doing something like this:

local desc = Instance.new('HumanoidDescription')
desc.Head = 11748988354
local model = game:GetService('Players'):CreateHumanoidModelFromDescription(desc , Enum.HumanoidRigType.R15, Enum.AssetTypeVerification.Always)

model.Parent = workspace

Basically, I had to create a whole new model out of the humanoid description. Doing so created a hierarchy more similar to my player hierarchy, so I wonder if it has to do with the difference between a player model and rig generated with the rig creator. Either way, you can create a rig out of the description to get the head to work.

Here is my post if that is of any use to you!
Dynamic head not applying to humanoid via humanoid description - Help and Feedback / Scripting Support - Developer Forum | Roblox

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.