So basically I want to copy the player head with their head accessories and position them. After several failure I’ve decided to ask you guys for help
Here’s the code that i tried:
for i,v in pairs(plrCharacter:GetChildren()) do
if v:IsA("Accessory") then
if v.AccessoryType == Enum.AccessoryType.Hat or Enum.AccessoryType.Hair or Enum.AccessoryType.Face then
local accessoryClone = v:Clone()
accessoryClone.Handle.Anchored = false
accessoryClone.Parent = workspace.PlaceHolderItem
end
end
end
Instead of checking the AccessoryType (which tends to be AccessoryType.Unknown), check for the relevant attachments inside the handle. Try something like this:
local validAttachments = {
'NeckAttachment';
'FaceFrontAttachment';
'FaceCenterAttachment';
'FaceFrontAttachment';
'HairAttachment';
'HatAttachment';
}
for _, accessory in plrCharacter:GetChildren() do
if not accessory:IsA('Accessory') then
continue
end
local handle = v:WaitForChild('Handle')
local didFindValidAttachment = false
for _, attachmentName in validAttachments do
if handle:FindFirstChild(attachmentName) then
didFindValidAttachment = true
break
end
end
if not didFindValidAttachment then
continue
end
local accessoryClone = accessory:Clone()
accessoryClone.Handle.Anchored = false
accessoryClone.Parent = workspace.PlaceHolderItem
end