Strange bug with adding a characters hair

Hi,

Bit of a strange bug, but I have a function that should retrieve a players’ character skin tone, face decal and hair accessory, and add them to a character for the game.

All of this used to work perfectly (when last checked about a week ago or so), however all of a sudden, after checking yesterday/today, both the setting of the skin tone AND face decal still work, however the hair Accessory feature no longer works? (So when they get put in game they have their personal avatars skin tone and face decal, but have no hair). Does anyone know why this is? My first thought is it could possibly be to do with some recent studio update that has rearranged the table hierarchy to obtain a players hair accessory, so if anyone who is relatively up to date with new features etc or this aspect of studio in general could give some insight, that would be much appreciated. The relevant function is below:

function module.GiveDetails(player)
	local playerAppearance = Players:GetCharacterAppearanceInfoAsync(player.userId)
	
	
--	local data = game:GetService("HttpService"):JSONDecode(playerAppearance)
	--print(data)
	local character = player.Character
	for index,asset in pairs(playerAppearance["assets"]) do
		
		if asset["assetType"] then
			local assetType = asset["assetType"]
			if assetType["name"] == "Face" then -- Checks if the asset type is a Face
				local faceId = asset["id"]
				local faceAsset = InsertService:LoadAsset(faceId)
				-- Loads the face asset into the game
				faceId = faceAsset.face.Texture-- Gets texture id of the face asset
				faceAsset:Destroy()
				character.Head.face.Texture = faceId
			end
			
			if assetType["name"] == "Hair Accessory" then
				local hairId = asset["id"]
				local hairAsset = InsertService:LoadAsset(hairId)
				hairId = hairAsset:FindFirstChildOfClass("Accessory")
				hairId.Parent = character
				hairAsset:Destroy()
				
				
			end
			
		end
		

	end

	local bodyColors = character:WaitForChild("Body Colors")
	local BodyColours = playerAppearance["bodyColors"]
	bodyColors.HeadColor = BrickColor.new(BodyColours["headColorId"])
	bodyColors.LeftArmColor = BrickColor.new(BodyColours["leftArmColorId"])
	bodyColors.LeftLegColor = BrickColor.new(BodyColours["leftLegColorId"])
	bodyColors.RightArmColor = BrickColor.new(BodyColours["rightArmColorId"])
	bodyColors.RightLegColor = BrickColor.new(BodyColours["rightLegColorId"])
	bodyColors.TorsoColor = BrickColor.new(BodyColours["torsoColorId"])
	
end

Thanks!

Try FindFirstChildWhichIsA. //

Also don’t check names, it could be called"truebluehair" etc

1 Like

Tried that, sadly players still aren’t getting hair on their character.

Sometimes InsertService inserts “Hat” as well, not Accessory alone.

Nothing is wrong with your code other than to include the Hat too.

1 Like

Hmm, as in game you can buy hats, so ideally id want it so that hats from the player aren’t inserted. Its very strange though as it always used to work, and now works 0% of the time. im not sure if the recent studio update had anything to do with this…

Okay, found the solution. After Encoding the table I found that Hair Accessory shouldve been HairAccessory, not sure if this has been changed or I somehow did this accidentally, but it works now.