Hey developers,
I’ve come across a problem in a game I am working on where I’m putting accessories on dummies in a viewport frame, so like a character customizer (which is exactly what it is). Now, accessories don’t automatically attach to the head on the client, which is why I need to use a script to make it attach.
This is the script I got from someone with a few changes:
return function(accessory, charModel)
local handle = accessory:FindFirstChild("Handle") --accessory:FindFirstChildWhichIsA("BasePart")
-- The hair must be welded because AddAccessory doesn't work locally
-- Noted 8/2/2021
local accessoryAttachment = handle:FindFirstChildWhichIsA("Attachment")
local characterAttachment = charModel.Head:WaitForChild(accessoryAttachment.Name)
--print(accessoryAttachment == nil, characterAttachment == nil)
local weld = Instance.new("Weld",handle)
accessory.Parent = charModel
weld.Part0 = charModel.Head
weld.Part1 = handle
weld.C0 = characterAttachment.CFrame
weld.C1 = accessoryAttachment.CFrame
--print(weld.C0, weld.C1)
weld.Parent = handle
end
It doesn’t really work, and doesn’t attach it. I’m wondering if there is a better way to do this, otherwise what would be a good fix to this.
Thank you.