You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I made a post yesterday trying to create a system that would take the user’s hair from their UserID to place it onto a smaller custom character. I managed to find a fix for yesterday’s issue thanks to help from the previous post but now I’ve run into another issue that I’m not exactly sure how to fix. Each hair has a different placement on the player’s head than normal. Keep in mind, that my character is half the size of a normal character. Though, on a normal character, it’s just fine.
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked on the Developer Hub and found similar issues but nothing that helped me just yet. Additionally, I’ve attempted to change the handle size of each generated hair to (1,1,1). To then hopefully, position it to the correct position. In short, it didn’t really help at all and was more of a useless attempt.
Hopefully, this isn’t that hard to fix. I’ll appreciate any help given my way.
The hair attachment in the Starter Characters head should be in the correct position. Though, the actual hair attachment in the hair accessory that is parented in the character seems different for each hair. I’ll attach some examples.
Hair Attachment on custom Starter Character head:
Both Head Hair Attachment and Hair Accessory Attachment:
This should work. It uses the WorldCFrame of the destination Attachment, and the CFrame of Attachment1 to properly move Part0 to its destination.
function Move_Part_By_Attachments(Part0 : BasePart, Attachment0 : Attachment, Attachment1 : Attachment)
-- Part0 : The target object you want to move.
-- Attachment0 : The attachment of the target object.
-- Attachment1 : The destination attachment.
local World_CFrame_GoTo = Attachment1.WorldCFrame
local Local_CFrame_Part0 = Attachment0.CFrame:Inverse() -- Must be inversed to properly adjust to Attachment1.
Part0.CFrame = World_CFrame_GoTo
Part0.CFrame *= Local_CFrame_Part0
end
Sorry, I’m relatively new to coding, I’ve tried your code, but I’m not sure I formatted it correctly. In the function inside the parentheses, does “Part0” act as a variable for the object (Handle/Basepart)? Sorry again, I’m not looking to be spoonfed code or anything, just a bit confused.
Script:
function Move_Part_By_Attachments(Part0 : Handle, Attachment0 : HairAttachment, Attachment1 : HeadAttach)
-- Part0 : The target object you want to move.
-- Attachment0 : The attachment of the target object.
-- Attachment1 : The destination attachment.
local Mesh = script.Parent:FindFirstChildWhichIsA("Accessory").Handle.Mesh
local Hair = Mesh.Parent.Parent
local HairAttachment = Hair.Handle.HairAttachment
local World_CFrame_GoTo = Attachment1.WorldCFrame
local Local_CFrame_Part0 = Attachment0.CFrame:Inverse() -- Must be inversed to properly adjust to Attachment1.
Part0.CFrame = World_CFrame_GoTo
Part0.CFrame *= Local_CFrame_Part0
end
Yes. The Handle is Part0, Attachment0 is the target attachment in the Handle (in your case, HairAttachment or HatAttachment) and Attachment1 is the attachment with the same name inside the Head of your character.
You’ll have to reset the weld too before firing this function, forgot to tell you.
Accessories are welded to the body part of the character, which has an attachment with a name that matches the Accessories’ attachment name. The weld is parented inside the Handle of the Accessory, and is named “AccessoryWeld”.
The kind of weld used is kinda hard to work with, so use the newer WeldConstraint weld instead, right after using Move_Part_By_Attachments. And yes, the code should be fine.