I have a round system that teleports you to a map and your avatar gets morphed into a R15 dummy with the correspondient color of the team. there is team pink, brown, black, and white and that is done.
The thing that i want to do now is grab the player’s Hair and put it in the dummy’s model and also change it’s color to the color of the dummy ofc. But i don’t have such as an idea on how to do that.
I know that i can use something called Humanoid:AddAccesory() but i don’t know how to use it.
also i know how to identify if an accesory is hair, by doing if Accesory.AccesoryType == Enum.AccesoryType.Hair then... but when i morph the player i lose the original character meaning that i lose the hair too, i need to know how to save that hair somewhere and how to put it in the dummy.
function MorphCharacter(DesiredMorph, PlayerChar)
local Morph = game.ReplicatedStorage.Teams:FindFirstChild(DesiredMorph):Clone()
Morph.Name = PlayerChar.Name
Morph.HumanoidRootPart.Anchored = false
Morph.PrimaryPart.CFrame = PlayerChar.Character.PrimaryPart.CFrame
-- Here it checks for Hair
for i,v in pairs(PlayerChar.Character:GetChildren()) do
if v:IsA("Accesory") then
if v.AccesoryType == Enum.AccessoryType.Hair then
print("Found Hair")
local ClonedHair = v:Clone()
PlayerChar.Character.Humanoid:AddAccesory(ClonedHair)
end
end
end
-- Here it changes the original player to the morph
PlayerChar.Character = Morph
Morph.Parent = game.Workspace
end
But that doesn’t print anything and does nothing, also no errors.
I don’t believe that every hair’s AccessoryType is Hair. What you can do is look into your character and see how the hair accessories are welded or attached to the head, then check for the accessories with the same attachments and/or similar weld properties.
I can’t do this for you because I am on mobile, however here’s an example:
-- Info: Every hair accessory has an attachment named "Something"
local hairs = {}
-- Get the head accessories.
for _, child in character:GetChildren() do
if not child:IsA("Accessory") then
continue
end
local attachment = child.Handle:FindFirstChildOfClass("Attachment")
if attachment.Name == "Something" then
table.insert(hairs, child:Clone())
end
end
-- Apply the accessories to the dummy.
for _, hair in hairs do
dummy.Humanoid:AddAccessory(hair)
end
Somewhere inside of the accessory, it may be the Handle, is a MeshPart. That MeshPart has two properties: one property that’s responsible for the shape, and one property that’s responsible for the texture. You can look into that and see if you can change the property of the texture via script.