Hi, I am working on a role playing game which relies on morphs. Unfortunately many of these morphs don't comply with the height of a Robloxian head, so hat giver scripts will have the hat floating above the player by a significant amount.
I am trying to make some hats using the Accessory class that will attach using a weld to a specific brick in the morph called Attach. This way, I can modify where hats appear on each morph.
The script mostly works, so the hat is duplicated and put in the correct brick. My main problem is that I don't know how to make two Attachments (one in the Attach brick in the player, and the other created inside the new hat using a script, both are named AttachMe) become one Weld when using a giver script to put the hat into the body.
debounce = true
function onTouched(hit)
if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
local a = Instance.new("Accessory")
local p = Instance.new("Part")
local a2 = Instance.new("Attachment")
a.Parent = hit.Parent.Chest1
a.Name = "WizardHat"
p.Parent = a
a2.Parent = p
a2.Name = "AttachMe"
p.Position = hit.Parent.Chest1.Attach.Position
p.Name = "Handle"
p.Anchored = false
p.formFactor = 0
p.Size = Vector3.new(5,4,2)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
wait(5)
debounce = true
end
end
script.Parent.Touched:connect(onTouched)
The new hat just falls onto the ground and cannot be picked up. It's a child of the player model, but the Attachments don't connect.
Any advice will be much appreciated!!

3 comments
(I updated this post to describe my problem better - after some research I discovered the differences between Accessories and Hats, but I am still pretty lost..)
I have recently made a model for this, I will give you link to the model as soon as I can. I apologize if I have come with to help too late
https://www.roblox.com/library/5934813856/Accessory-Morph just edit the part handle as you please.