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?