Humanoid:ApplyDescription() returning an error

Quick Context


I’m making a commission which is an inspect tool, here you could wear/unwear things from your avatar, but the Humanoid:ApplyDescription() is returning this error:
Humanoid::ApplyDescription() The current HumanoidDescription does not match the assets currently applied to the character. Did you edit the character?


Useful Information


ApplyDescription() is being called from the Client.
LocalScript is located under a ScreenGui.

FunctionCode (Main Code)
local function Modify_plrPreview()
	local oldHD:HumanoidDescription = PlayerPreview:WaitForChild("Model").Humanoid:FindFirstChildOfClass("HumanoidDescription")
	
	for _,v in BackYourOutfit.Equipped.ScrollingFrame:GetChildren() do
		if v:IsA("ImageButton") then
			v:Destroy()
		end
	end
	
	local newHD = Instance.new("HumanoidDescription")
	
	for _,v in AccessoryType do
		for index,property in v do
			local worked,result = pcall(function()
				return newHD[index]
			end)
			
			if worked then
				local why = helpmeeeeeIcantAnymore(property)

				if not why then continue end
				newHD[index] = why[1]
			end
		end
	end
	
	for _,v in newHD:GetAccessories(true) do
		PX_CreateButton(v.AssetId)
	end
	
	PX_CreateButton(newHD.Shirt)
	PX_CreateButton(newHD.Pants)

	local Hum:Humanoid = PlayerPreview:WaitForChild("Model").Humanoid
	for _,v in Hum:GetChildren() do
		if v:IsA("HumanoidDescription") or v.Name == "HumanoidDescription" then
			v:Destroy()
		end
	end
	Hum:ApplyDescriptionReset(oldHD)
	Hum:ApplyDescription(newHD)
	newHD:Destroy()
end
AccessoryType Info
local AccessoryType = {LayeredClothing = {
	TShirt = 0,

	Shirt = 0,

	Pants = 0,

	Jacket = 0,

	Sweater = 0,

	Shorts = 0,

	LeftShoe = 0,

	RightShoe = 0,

	DressSkirt = 0
},

ClassicClothing = {
	GraphicTShirt = 0,

	Shirt = 0,

	Pants = 0
},

Accessories = {
	BackAccessory = 0,

	FaceAccessory = 0,

	FrontAccessory = 0,

	HairAccessory = 0,

	HatAccessory = 0,

	NeckAccessory = 0,

	ShoulderAccessory = 0,

	WaistAccessory = 0
},

Animation = {
	ClimbAnimation = 0,

	FallAnimation = 0,

	IdleAnimation = 0,

	JumpAnimation = 0,

	MoodAnimation = 0,

	RunAnimation = 0,

	SwimAnimation = 0,

	WalkAnimation = 0
},

BodyParts = {
	Face = 0,

	Head = 0,

	LeftArm = 0,

	LeftLeg = 0,

	RightArm = 0,

	RightLeg = 0,

	Torso = 0
},

BodyColors = {
	HeadColor = Color3.new(1, 1, 1),

	LeftArmColor = Color3.new(1, 1, 1),

	LeftLegColor = Color3.new(1, 1, 1),

	RightArmColor = Color3.new(1, 1, 1),

	RightLegColor = Color3.new(1, 1, 1),

	TorsoColor = Color3.new(1, 1, 1)
},

Scale = {
	BodyTypeScale = 0,

	DepthScale = 0.9,

	HeadScale = 0.95,

	HeightScale = 0.9,

	ProportionScale = 0,

	WidthScale = 0.75
}}
Screenshots

The items are imagebuttons.

FULL CODE (🚨Alert! there are things that might hurt your vision.🚨)
local RS = game:GetService('ReplicatedStorage')
local Player = game.Players.LocalPlayer
local module = require(RS:WaitForChild('Container'))
local BackgroundOutfit = script.Parent:WaitForChild('Background')
local BackYourOutfit = script.Parent:WaitForChild('OutfitInspect')
local ButtonsExtra = script.Parent.Parent:WaitForChild('ExtraButtons')
local PlayerPreview

local function ExitMenu()
	module.AnimationGui(BackYourOutfit, UDim2.fromScale(0,0), UDim2.fromScale(.5,.5), UDim2.fromScale(.4,.4), UDim2.fromScale(.5,.5), false)
	module.ProximityPromptService.Enabled = true
	module.ClearScroll(BackYourOutfit.CW:FindFirstChild("Items"))
	module.ClearActions(module.Actions)
	BackYourOutfit.CW.Preview.ViewportFrame.WorldModel:ClearAllChildren()
end

local function CreateCharacter(Character:Model)
	local Cha = Character:Clone()
	Cha.PrimaryPart = Cha:FindFirstChild('HumanoidRootPart')
	Cha:PivotTo(CFrame.new(0,0,0))
	local Camera = Instance.new('Camera', BackYourOutfit.CW.Preview.ViewportFrame.WorldModel)
	BackYourOutfit.CW.Preview.ViewportFrame.CurrentCamera = Camera
	Camera.CameraType = Enum.CameraType.Scriptable
	Cha.Parent = BackYourOutfit.CW.Preview.ViewportFrame.WorldModel
	Camera.CFrame = CFrame.new(Cha.HumanoidRootPart.Position + Vector3.new(-0.6, -1.25, -7)) * CFrame.Angles(0,math.rad(-180),0) 
	
	return Cha
end

local function CreatedIcon(ItemId:number)
	if ItemId == 0 then return 0 end
	local Item
	local nice, errorMessage = pcall(function()
		Item = module.MarketplaceService:GetProductInfo(ItemId, Enum.InfoType.Asset)
	end)
	if nice and Item then
		local Clone = module.ButtonOutfit:Clone()
		Clone.NameP.Text = Item.Name
		Clone.Price.Text = Item.PriceInRobux or 'Not for sale!'
		Clone.IMG.Image = string.format(module.URLimage, ItemId)
		Clone.Parent = BackYourOutfit:FindFirstChild('CW'):FindFirstChild("Items")
		local cloneWear = Clone:FindFirstChild("Wear")
		if Item.IsForSale then
			Clone.MouseButton1Click:Connect(function()
				module.MarketplaceService:PromptPurchase(Player, ItemId, true)
				module.MarketplaceService.PromptPurchaseFinished:Connect(function(plr, iditem, ispurchased)
					print("FirstYES")
					print(iditem)
					print(ItemId)
					if iditem == ItemId then
						print("Yes")
						game.ReplicatedStorage.BuyEvent:FireServer(ItemId)
					end
				end)
			end)
		else
			Clone.RBX:Destroy()
		end
		
		return Item.PriceInRobux or 0
	else
		return 0
	end
end
PlayerPreview = BackYourOutfit.AvatarBG.ViewportFrame.WorldModel

local function helpmeeeeeIcantAnymore(rawValue: string | number)

	local nice, errorMessage = pcall(function()
		return module.MarketplaceService:GetProductInfo(tonumber(rawValue), Enum.InfoType.Asset)
	end)

	if nice then
		local value = string.split(rawValue, ",")
		if value[1] ~= nil and value[2] == nil and value[3] == nil then
			return {string.format("%s",value[1]), value}
		elseif value[1] ~= nil and value[2] ~= nil and value[3] == nil then
			return {string.format("%s,%s",value[1], value[2]), value}
		elseif value[1] ~= nil and value[2] ~= nil and value[3] ~= nil then
			return {string.format("%s,%s,%s",value[1], value[2], value[3]), value}
		end
	end
	return 
end

local initialHD = game:GetService("Players"):GetHumanoidDescriptionFromUserId(Player.UserId)

local AccessoryType = {LayeredClothing = {
	TShirt = 0,

	Shirt = 0,

	Pants = 0,

	Jacket = 0,

	Sweater = 0,

	Shorts = 0,

	LeftShoe = 0,

	RightShoe = 0,

	DressSkirt = 0
},

ClassicClothing = {
	GraphicTShirt = 0,

	Shirt = 0,

	Pants = 0
},

Accessories = {
	BackAccessory = 0,

	FaceAccessory = 0,

	FrontAccessory = 0,

	HairAccessory = 0,

	HatAccessory = 0,

	NeckAccessory = 0,

	ShoulderAccessory = 0,

	WaistAccessory = 0
},

Animation = {
	ClimbAnimation = 0,

	FallAnimation = 0,

	IdleAnimation = 0,

	JumpAnimation = 0,

	MoodAnimation = 0,

	RunAnimation = 0,

	SwimAnimation = 0,

	WalkAnimation = 0
},

BodyParts = {
	Face = 0,

	Head = 0,

	LeftArm = 0,

	LeftLeg = 0,

	RightArm = 0,

	RightLeg = 0,

	Torso = 0
},

BodyColors = {
	HeadColor = Color3.new(1, 1, 1),

	LeftArmColor = Color3.new(1, 1, 1),

	LeftLegColor = Color3.new(1, 1, 1),

	RightArmColor = Color3.new(1, 1, 1),

	RightLegColor = Color3.new(1, 1, 1),

	TorsoColor = Color3.new(1, 1, 1)
},

Scale = {
	BodyTypeScale = 0,

	DepthScale = 0.9,

	HeadScale = 0.95,

	HeightScale = 0.9,

	ProportionScale = 0,

	WidthScale = 0.75
}}

for i,v in AccessoryType do
	for index,property in v do
		local worked,returnproperty = pcall(function()
			return initialHD[index]
		end)
		if worked then
			AccessoryType[i][index] = returnproperty
		end
	end
end
print(AccessoryType)
task.wait(.5)
local function Modify_plrPreview()
	local oldHD:HumanoidDescription = PlayerPreview:WaitForChild("Model").Humanoid:FindFirstChildOfClass("HumanoidDescription")
	
	for _,v in BackYourOutfit.Equipped.ScrollingFrame:GetChildren() do
		if v:IsA("ImageButton") then
			v:Destroy()
		end
	end
	
	local newHD = Instance.new("HumanoidDescription")
	
	for _,v in AccessoryType do
		for index,property in v do
			local worked,result = pcall(function()
				return newHD[index]
			end)
			
			if worked then
				local why = helpmeeeeeIcantAnymore(property)

				if not why then continue end
				newHD[index] = why[1]
			end
		end
	end
	
	for _,v in newHD:GetAccessories(true) do
		PX_CreateButton(v.AssetId)
	end
	
	PX_CreateButton(newHD.Shirt)
	PX_CreateButton(newHD.Pants)

	local Hum:Humanoid = PlayerPreview:WaitForChild("Model").Humanoid
	for _,v in Hum:GetChildren() do
		if v:IsA("HumanoidDescription") or v.Name == "HumanoidDescription" then
			v:Destroy()
		end
	end
	Hum:ApplyDescriptionReset(oldHD)
	Hum:ApplyDescription(newHD)
	newHD:Destroy()
end

function PX_CreateButton(ItemID: number)
	if ItemID == 0 then return 0 end
	
	local newItem
	
	local NP,EM = pcall(function()
		newItem = module.MarketplaceService:GetProductInfo(ItemID, Enum.InfoType.Asset)
	end)
	
	if NP and newItem then
		local newButton = module.Template:Clone()
		newButton.Image = string.format(module.URLimage, ItemID)
		newButton.Parent = BackYourOutfit.Equipped.ScrollingFrame
		
		newButton.MouseButton1Click:Connect(function()
			for i,v in AccessoryType do
				for index, property in v do
					local why = helpmeeeeeIcantAnymore(property)
					if not why then continue end
					if tonumber(why[2][1]) == ItemID or tonumber(why[2][2]) == ItemID or tonumber(why[2][3]) == ItemID then
						print("Oh!")
						AccessoryType[i][index] = why 
					end
				end
			end
			Modify_plrPreview()
		end)
	end
end

local function CreateButton(ItemId:number)
	if ItemId == 0 then return 0 end
	local Item
	local nice, errorMessage = pcall(function()
		Item = module.MarketplaceService:GetProductInfo(ItemId, Enum.InfoType.Asset)
	end)
	if nice and Item then
		local Clone = module.ButtonOutfit:Clone()
		Clone.NameP.Text = Item.Name
		Clone.Price.Text = Item.PriceInRobux or 'Not for sale!'
		Clone.IMG.Image = string.format(module.URLimage, ItemId)
		Clone.Parent = BackYourOutfit:WaitForChild('CW')
		if Item.IsForSale then
			Clone.MouseButton1Click:Connect(function()
				module.MarketplaceService:PromptPurchase(Player, ItemId, true)
				module.MarketplaceService.PromptPurchaseFinished:Connect(function(plr, iditem, ispurchased)
					print("FirstYES")
					print(iditem)
					print(ItemId)
					if iditem == ItemId then
						print("Yes")
						game.ReplicatedStorage.BuyEvent:FireServer(ItemId)
					end
				end)
			end)
		end
	end
end

local function MoveCharacterInView(cha:Model)
	local press, posix = false, nil
	
	table.insert(module.Actions, module.UIS.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1 then
			if press then
				local eded, move
				eded = module.UIS.InputEnded:Connect(function(input2)
					if input2 == input then
						eded:Disconnect()
						move:Disconnect()
						posix = nil
					end
				end)
				move = module.UIS.InputChanged:Connect(function(input3)
					if posix then
						cha:PivotTo(cha:GetPivot()*CFrame.fromEulerAnglesXYZ(0,((input3.Position.X-posix)*0.025),0))
					end
					posix = input3.Position.X
				end)
			end
		end
	end))
	table.insert(module.Actions, BackYourOutfit.CW.Preview.ViewportFrame.MouseEnter:Connect(function(x,y)
		press = true;
	end))
	table.insert(module.Actions, BackYourOutfit.CW.Preview.ViewportFrame.MouseLeave:Connect(function()
		press = false;
	end))
end

local function ViewOutfit(npc:Model)
	local HD:HumanoidDescription = npc:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("HumanoidDescription")
	local TotalPrice = 0
	BackYourOutfit.CW.Cost.Price.Text = tostring(TotalPrice.." Robux")
	module.ProximityPromptService.Enabled = false
	local Char
	task.spawn(function()
		for _,Assets in HD:GetAccessories(true) do
			TotalPrice += CreatedIcon(Assets.AssetId)
		end
		Char = CreateCharacter(npc)
		MoveCharacterInView(Char)
		TotalPrice += CreatedIcon(HD.Shirt)
		TotalPrice += CreatedIcon(HD.Pants)
		TotalPrice += CreatedIcon(HD.GraphicTShirt)

		BackYourOutfit.CW.Cost.Price.Text = tostring(TotalPrice.." Robux")
	end)
	
	task.spawn(function()
		module.AnimationGui(BackYourOutfit, UDim2.fromScale(0.668,0.63), UDim2.fromScale(.5,.5), UDim2.fromScale(0,0), UDim2.fromScale(.5,.5), true)
	end)

	table.insert(module.Actions, BackYourOutfit.Exit.MouseButton1Click:Connect(ExitMenu))

	table.insert(module.Actions, BackYourOutfit.CW.Wear.MouseButton1Click:Connect(function()
		module.Events.ChangedCharacter:FireServer(HD)
		ExitMenu()
	end))
end

local function ViewYourOutfit()
	task.spawn(function()
		if BackYourOutfit.Visible then
			module.ClearScroll(BackYourOutfit.CW)
			module.ClearActions(module.Actions2)
			BackYourOutfit.Visible = false
			--module.AnimationGui(BackYourOutfit, UDim2.fromScale(0,0), UDim2.fromScale(.5,.8), UDim2.fromScale(.4,.15), UDim2.fromScale(.5,.8), false)
		else
			local HD:HumanoidDescription = Player.Character:FindFirstChild('HumanoidDescription', true)
			for _,Assets in HD:GetAccessories(true) do
				task.spawn(function()
					CreateButton(Assets.AssetId)
				end)
			end
			CreateButton(HD.Shirt)
			CreateButton(HD.Pants)
			CreateButton(HD.GraphicTShirt)
			--task.spawn(function()
			--	module.AnimationGui(BackYourOutfit, UDim2.fromScale(.4,.15), UDim2.fromScale(.5,.8), UDim2.fromScale(0,0), UDim2.fromScale(.5,.8), true)
			--end)
			BackYourOutfit.Visible = true
			table.insert(module.Actions2, BackYourOutfit.Exit.MouseButton1Click:Connect(ViewYourOutfit))
			table.insert(module.Actions2, HD:GetPropertyChangedSignal('Parent'):Connect(ViewYourOutfit))
		end
	end)
end

local function AddAtta()
	local ListCha = module.Events.SearchNPCS:InvokeServer()
	spawn(function() module.UpdateDistance(ListCha) end)
	for _,v:Model in ListCha do
		local Proxi:ProximityPrompt = module.AddAtta(v:FindFirstChild('HumanoidRootPart'))
		
		Proxi.Triggered:Connect(function()
			if v:FindFirstChild('HumanoidDescription',true) then
				ViewOutfit(v)
			end
		end)
	end
end

module.UIS.InputBegan:Connect(function(input, processed)
	if processed or module.Touch then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		local inputposi = input.Position
		module.Touch = module.UIS.InputEnded:Connect(function(input2)
			if input2 == input then
				module.Touch:Disconnect()
				local ray = workspace:Raycast(
					workspace.CurrentCamera.CFrame.Position,
					(Player:GetMouse().Hit.Position-workspace.CurrentCamera.CFrame.Position).Unit * 50
				)
				if (inputposi-input2.Position).Magnitude < 2 and ray and ray.Instance.Parent == Player.Character then
					ViewYourOutfit()
				elseif (inputposi-input2.Position).Magnitude < 2 and ray and ray.Instance.Parent:FindFirstChildOfClass("Humanoid") and ray.Instance.Parent:FindFirstChild("Clothing") then
					ViewOutfit(ray.Instance.Parent)
				end
				module.Touch = nil
			end
		end)
	end
end)

ButtonsExtra:WaitForChild('Buy').MouseButton1Click:Connect(function()
	ViewYourOutfit()
end)

local bool = true

ButtonsExtra:WaitForChild('ResetNPC').MouseButton1Click:Connect(function()
	module.Events.ChangedCharacter:FireServer(Player:FindFirstChild('HumanoidDescription'))
end)

local function ChangedText(huma:Humanoid)
	if huma.RigType == Enum.HumanoidRigType.R15 then
		ButtonsExtra:WaitForChild('r6/r15').Text = 'R6'
	else
		ButtonsExtra:WaitForChild('r6/r15').Text = 'R15'
	end
end
ChangedText(Player.Character:WaitForChild('Humanoid'))
ButtonsExtra:WaitForChild('r6/r15').MouseButton1Click:Connect(function()
	if bool then
		bool = false
		local boolnew, characternew = module.Events.ChangeR6:InvokeServer()
		workspace.CurrentCamera.CameraSubject = characternew
		ChangedText(characternew)
		bool = boolnew
	end
end)

AddAtta()
Modify_plrPreview()

What i’m trying to achieve:

  • Basically just buttons that unwears your equipped accessory, which updates your avatar in the viewportframe.

Ps: This is my first time trying to work with HumanoidDescription, it really seems pretty confusing to work with.

If you need more information about what i’m trying to achieve, please, make sure to be clear in what info you need specifically, i’ll try my best to explain it clearly to you.

Edit: If you have any tips of optimization and good practice related to this code, please tell me^^

Edit2: The error isn’t happening anymore, i modified the script a bit and now i’m parenting the newHd to the humanoid and stuff. The humanoid description is being modified, however it isn’t applying to the model, in the properties i can see clearly that the humanoid description is in fact being modified, i just need to apply it, which isn’t happening. (No error is being returned anymore, basically i do not know how to solve this problem.)

1 Like

This might not be very helpful but I think the issue lies somewhere within how you make the new humanoid description, because the error suggests there is an issue with the humanoiddescription you’re trying to apply.

1 Like

Yeah, i tried something new right now, the error dissappeared but it stills not update the player avatar, even tho the humanoid description is in fact being modified, i just need to find a way to apply this humanoid description to the model.

bumping this post because i really need help

1 Like

Try using the HumanoidDescription that already exists under the Humanoid instead of creating a new one.

local function changeAvatar(hum, properties)
    local description = hum:WaitForChild("HumanoidDescription")

    for property, value in pairs(properties) do
        description[property] = value
    end
    
    hum:ApplyDescription(description)
end

Just did that and it doesnt works, i’m surprised that there isn’t literally ANY error, it just doesnt works, i’m about to make a workaround if i dont find any way to fix that.

Problem Solved, used set accessories and :gsub aswell to filter some stuff.

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