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:
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! :))