Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hair isn't positioned correctly?

I'm trying to make a character creation system for my game. Everything works fine, except the hair. Whenever I change the hair by pressing the left/right arrow, the hair floats above the character's head.

-- server script

local hairs = {
    "http://www.roblox.com/asset/?id=398987591",
    "http://www.roblox.com/asset/?id=76056263",
    "http://www.roblox.com/asset/?id=13332444",
    "http://www.roblox.com/asset/?id=16627529",
    "http://www.roblox.com/asset/?id=62246019",
    "http://www.roblox.com/asset/?id=83293901",
    "http://www.roblox.com/asset/?id=167549828",
    "http://www.roblox.com/asset/?id=13070796",
    "http://www.roblox.com/asset/?id=164382853",
    "http://www.roblox.com/asset/?id=47963332",
    "http://www.roblox.com/asset/?id=29713297",
    ""
}

local hairCount = 1
local hairCount2 = 1

local headAttachment = char.Hed:FindFirstChildOfClass("Attachment") -- this is not an error, i named it "Hed" so the name of the npc doesn't appear.

game.ReplicatedStorage.Remotes.HairLeft.OnServerEvent:Connect(function()	
	hairCount = hairCount - 1
	
	if hairCount == 0 then
		hairCount = #hairs
		char.Hair.Handle.Mesh.MeshId = hairs[hairCount]
		char.Hair.Handle.Attachment.Position = headAttachment.Position
	else
		char.Hair.Handle.Mesh.MeshId = hairs[hairCount]
		char.Hair.Handle.Attachment.Position = headAttachment.Position
	end
end)

game.ReplicatedStorage.Remotes.HairRight.OnServerEvent:Connect(function()
	hairCount = hairCount + 1
	
	if hairCount > 12 then
		hairCount = 1
		char.Hair.Handle.Mesh.MeshId = hairs[hairCount]
		char.Hair.Handle.Attachment.Position = headAttachment.Position
	else
		char.Hair.Handle.Mesh.MeshId = hairs[hairCount]
		char.Hair.Handle.Attachment.Position = headAttachment.Position
	end
end)

In-game: link Sadly, it only works for the default hair that you get in the customization. How should I make it so that the hair gets positioned correctly on the player's head?

1 answer

✓ Accepted answer

Change the accessory position or offset the mesh

1 comment

0

i'll let you know if it works. i'm currently modifying offset via script.

This discussion is preserved as it was. New answers, comments, and votes are closed.