Making hair have an appropriate offset

How would I make my hair mesh nicely fit on my lil assistants head?Current head size:
0.781, 0.393, 0.391
What I want to do is make it so any hair that is added to the guys head will rest nicely on it, I could go through this hat by hat and manually do it for all however this is inefficient and the offset would be too much if the player was not facing front
What could possibly make it so any hair would nicely fit depending on its scale? (mesh scale is set to
.4, .4, .4)
local Assistant = plr.Character.Assistant

        local Part = Instance.new("Part")

        Part.Parent = Assistant.Head

        Part.Size = Assistant.Head.Size

        Part.CFrame = CFrame.new(Assistant.Head.Position) + Vector3.new(-0, 0.05, 0.1)

        Part.Orientation = Assistant.Head.Orientation

        Part.Anchored = false

        local Mesh = Instance.new("SpecialMesh")

        Mesh.Parent = Part

        Mesh.Scale = Vector3.new(0.4, 0.4, 0.4)

        Mesh.MeshId = "TheIdIWilluseForTheMeshIsHere"

        local Weld = Instance.new("WeldConstraint")

        Weld.Parent = Assistant.HumanoidRootPart

        Weld.Part0 = Assistant.Head

        Weld.Part1 = Part

        Weld.Part1 = Part
2 Likes

What I Know So Far


For my solutions, I’d usually apply an accessory with a HairAttachment in the Handle. I’m uncertain whether the hair scales with the character size when shrunk.

I don’t see anything called a Hair attachment in the explorer? Does this go by another name as well?

By the way, I forgot to mention:
HairAttachment is the same as Attachment. The thing is that you have to name it HairAttachment.

1 Like

What do I need to modify in order to make this work?
local remote = game.ReplicatedStorage.RemoteEvents.Test

remote.OnServerEvent:Connect(function(plr)

local Assistant = plr.Character.Assistant

local Part = Instance.new("Part")

Part.Parent = Assistant.Head

Part.Position = Assistant.Head.Position

Part.Anchored = false

local HairAttachment = Instance.new("Attachment")

HairAttachment.Parent = Part

HairAttachment.Name = "HairAttachment"

local Accessory = Instance.new("Accessory")

Accessory.Parent = Part

local Mesh = Instance.new("SpecialMesh")

Mesh.Parent = Part

Mesh.MeshId = "http://www.roblox.com/asset?id=375815502"

local Weld = Instance.new("WeldConstraint")

Weld.Parent = Assistant.HumanoidRootPart

Weld.Part0 = Assistant.Head

Weld.Part1 = Part

end)

Ouch, I didn’t think of a created hair instance, I was thinking about storing the preset hairs inside the ServerStorage and parenting the accessory directly on the character.

I’ll check what I can do later on.

1 Like

Alrighty, would parenting it be more efficient than creating a new instance? I’ll do it for now anyways until you get back to me on that instance (hopefully) since I’m rather stuck here. I appreciate the help though.

(marked as a solution until a more efficient way is found since it is, technically a solution and doesn’t look like anyone else intends to reply.)

Yes.

The Handle is a BasePart which you’ll apply the mesh on. Make sure these conditions are met:

  • The Accessory is the parent of the Handle.
  • The HairAttachment is child of the Handle.
  • The Accessory is in ServerStorage initially.
  • A script should clone and parent the accessory on the character only, you may tweak the HairAttachment for the desired placement.

I think you could create a new instance, but the problem is that it is difficult to maintain it consistently for all scales. An accessory would fix that in no time.

4 Likes
local remote = game.ReplicatedStorage.RemoteEvents.Test
remote.OnServerEvent:Connect(function(plr)
local Assistant = plr.Character.Assistant
local AH = Assistant.Head
game.ServerStorage.Hat:Clone().Parent = AH
end)

image


Ah right, also another issue appears to be that it adds the hat to the avatar many times…or in this case far away from the avatar. Regardless it’s replicating itself for some odd reason.

Localscript in the image button
local remote = game.ReplicatedStorage.RemoteEvents:WaitForChild(“Test”)

game:GetService("UserInputService").InputBegan:Connect(function(iobj, gp)

script.Parent.MouseButton1Down:Connect(function(clicked)

remote:FireServer()

end)

end)

You don’t parent it to the head, I specifically mentioned Character.

2 Likes

image
I mean the fella’s sure cute and so far the positioning is working but now the size has gone all awry.

I have to look this up when I arrive home if this does not work:

Try scaling up the hair in ServerStorage to normal size. It seems to scale automatically.

1 Like

Appears to be working now, just needs some adjustment. I appreciate the help yet again Operatik! :slight_smile:

1 Like

The accessory and attachment method only works if you’re using AddAccessory or rather that’s how it should be. If you are using accessories, the canonical way to append them to characters is not by parenting but by doing the following:

  • A Handle BasePart under an Accessory object
  • An attachment that is named the same as one within the character
  • Call AddAccessory on the character’s humanoid and pass the accessory as an argument

AddAccessory automatically “matches up” accessories. For example, you have a hair accessory. You must name the attachment “HairAttachment”. Once AddAccessory is called, it will attach the HairAttachment from the accessory to the HairAttachment of the character.

1 Like