How to add hair in a new character (Just a dummy)

Hello.

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.

the dummies are like this:
image

Also i’m doing this in a ServerScript.

Thanks in advice!

1 Like

Copy the player’s hair and store it inside of a variable before you morph the player. Then add that hair to the dummy. Here’s an example:

local hairClone = --[[Location of the hair]]:Clone()

-- Morph the player..

-- Add the hair to the dummy.
dummy.Humanoid:AddAccessory(hairClone)

I have this code right here:

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.

Edit: My avatar has hair :joy:

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

Well, at least my hair has the AccesoryType option in hair, also i saw that the hairs have a HairAttachment should i check that instead?

Yes. That is what I meant with my example.

Well thank you, i only changed some things but your method of AddAccessory works!!

Nvm i figured it out

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.

Yes i made the TextureID nil and changed the color of the hair to the color of the dummy and it works

This is the result:
image

1 Like

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