HumanoidDescription failing to load pants/shirt ids sometimes

So this problem is related to clothing (shirts/pants). Occasionally when I give a player a shirt/pants id from my selection of outfits in my game it will sometimes not load parts of their clothing.

Yes, it’s an uncommon thing, however it just gives me ocd whenever it happens. I don’t know how to solve it. I tried setting my clothing to other ids, then reverting to see if it reloads the outfit but it just won’t do that.

Can you provide the code to us so we can see what the issue might be? Other than that, I think you need to delete the current clothing first, then put on the new clothing. Make sure you also wrap both of these codes in a pcall to be sure the new clothing loads properly along with deleting the old ones.

@DefiniteMagic

I use applydescription to reload the clothing. Doesn’t that by default remove the shirts/pants and add in new ones?

Here’s the part of the code where I load the player’s clothing/body colors:

local Player = game.Players:GetPlayerFromCharacter(character)
		local ID
		
		local succ, fai = pcall(function()
			ID = game.Players:GetHumanoidDescriptionFromUserId(Player.UserId)
		end)
		if fai then
			print(fai)
		end
		
		local HumanoidDescription = humanoid:GetAppliedDescription()
		shirtid = gameresources.clothingids[tostring(playerfolder.clothingid.Value)]["Shirt"].Value
		pantsid = gameresources.clothingids[tostring(playerfolder.clothingid.Value)]["Pants"].Value
		HumanoidDescription.Shirt = shirtid
		HumanoidDescription.Pants = pantsid
		HumanoidDescription.FaceAccessory = 0

		local bc = BrickColor.new(playerfolder.skincolor.Value)
		local bccolor = bc.Color
		HumanoidDescription.HeadColor = bccolor
		HumanoidDescription.TorsoColor = bccolor
		HumanoidDescription.RightArmColor = bccolor
		HumanoidDescription.LeftArmColor = bccolor
		HumanoidDescription.RightLegColor = bccolor
		HumanoidDescription.LeftLegColor = bccolor
		if ID then
			HumanoidDescription.HairAccessory = ID.HairAccessory
		end
		
		wait(1)
		
		humanoid:ApplyDescription(HumanoidDescription)

I didn’t know about GetAppliedDescription() so I looked it up on the roblox dev resource page. It doesn’t say anything about reloading the avatar, but I might have missed that point by not reading more thoroughly. Can you provide errors too? Right now I will now try to edit your code.

There was no errors other than ‘HumanoidDescription failed to load pants id set to default’ yada yada

It was really tough to fix your code since I didn’t have your full code (this left errors as there were undefined variables and I got confused a little).

I did try to rewrite the entire code. If you want I can try implementing this feature in roblox that gets the avatar with all the info game.Players:GetCharacterAppearanceInfoAsync()

local Player = game.Players:GetPlayerFromCharacter(character)

local succ, fai = pcall(function()
	local bccolor = bc.Color
	local ID = game.Players:GetHumanoidDescriptionFromUserId(Player.UserId)
	
	for i, v in pairs(Player:GetChildren()) do 
		if v:IsA("Part") then 
			v.BrickColor = bccolor--change body colors
		end
		
		if v:IsA("Accessory") then
			v:Destroy() --if you dont want accessories to be deleted then delete these lines
		end
	end

	local shirt = Player:FindFirstChildWhichIsA("Shirt")
	if not shirt then
		shirt = Instance.new("Shirt", Player)
	end
	local pants = Player:FindFirstChildWhichIsA("Pants")
	if not pants then
		pants = Instance.new("Pants", Player)
	end
	
	shirt.ShirtTemplate = shirtid
	pants.PantsTemplate = pantsid
	
	if ID then
		Player.HairAccessory = ID.HairAccessory
	end
end)

if fai then
	print(fai)
end

Usually it’s a one off thing. Sometimes meshes and audio fail to load for me and the game breaks sometimes. It’s probably a good idea to wrap everything in checks just to make sure they work and load propery