NPC Isn't Properly Copying/Morphing Into Player's Avatar

hello! ive made a local script (parented under startercharacterscripts) thats supposed to make an NPC turn into/copy the players current avatar (R6).

everything works, but i don’t see any hair or accessories and there are NO output errors or warnings. when i test, the items are clearly in the NPC, i just can’t visibly see it on the NPC.

here’s a screenshot of the NPC:
avatar

here’s my local script:

local npc = workspace:FindFirstChild("NPC")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

if not npc then
	warn("NPC not found in the workspace.")
	return
end

if not character then
	warn("Player character not found.")
	return
end


npc:WaitForChild("Torso")
character:WaitForChild("Torso")


wait(0.1)


local function copyAppearance(fromCharacter, toNPC)
	
	for _, part in ipairs(toNPC:GetChildren()) do
		if part:IsA("CharacterMesh") or part:IsA("Accessory") or part:IsA("Clothing") then
			print("Removing part: " .. part.Name)
			part:Destroy()
		end
	end

	for _, item in ipairs(fromCharacter:GetChildren()) do
		if item:IsA("CharacterMesh") then
			local meshClone = item:Clone()
			meshClone.Parent = toNPC
			print("Copied CharacterMesh: " .. item.Name)
		elseif item:IsA("Accessory") then
			local accessoryClone = item:Clone()
			accessoryClone.Parent = toNPC

			
			local handle = accessoryClone:FindFirstChild("Handle")
			if handle then
				local attachment = handle:FindFirstChildWhichIsA("Attachment")
				if attachment then
					
					local bodyPart = toNPC:FindFirstChild(attachment.Name) 
					if not bodyPart then
						
						if attachment.Name == "HatAttachment" or attachment.Name == "HairAttachment" then
							bodyPart = toNPC:FindFirstChild("Head")
							
						elseif attachment.Name == "NeckAttachment" then
							bodyPart = toNPC:FindFirstChild("Torso")
						end
					end

					if bodyPart then
						handle.Parent = bodyPart 
						print("Accessory attached to: " .. bodyPart.Name)
					else
						warn("No matching body part for attachment: " .. attachment.Name)
					end
				else
					warn("No attachment found in accessory handle: " .. accessoryClone.Name)
				end
			end

			print("Copied Accessory: " .. item.Name)
		elseif item:IsA("Clothing") then
			local clothingClone = item:Clone()
			clothingClone.Parent = toNPC
			print("Copied Clothing: " .. item.Name)
		elseif item:IsA("BodyColors") then
			local bodyColorsClone = item:Clone()
			bodyColorsClone.Parent = toNPC
			print("Copied BodyColors")
		end
	end
end


if npc:FindFirstChild("Torso") and character:FindFirstChild("Torso") then
	print("Both NPC and player character are using R6.")
	copyAppearance(character, npc)
else
	warn("Either NPC or player character is not using R6.")
end

any help is GREATLY appreciated! :))

1 Like

What do you mean by this exactly? Are the accessories in workspace or you just know that avatar has them put on?

yes, the avatar has them put on, i just cant see any accessories being displayed.

I had the same problem once and I fixed it by copying every property of the attachement I believe

nevermind! i did some scrolling around the devforum and found a really simple fix!:

local Oldhumanoid = game.Workspace:FindFirstChild("NPC").Humanoid

local localPlayer = game.Players.LocalPlayer
local function applyAppearance()
	local humanoidDescription = game.Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId)
	task.wait(0.5)

	local Newhumanoid = Oldhumanoid:Clone()
	Newhumanoid.Parent = game.Workspace:FindFirstChild("NPC")
	Oldhumanoid:Destroy()
	Newhumanoid:ApplyDescription(humanoidDescription)
end

applyAppearance()
3 Likes

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