Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hair isn't positioned correctly?

Asked by
bluzorro 417 Moderation Voter
4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Change the accessory position or offset the mesh

0
i'll let you know if it works. i'm currently modifying offset via script. bluzorro 417 — 4y
Ad

Answer this question