I have tested my method for over 1 hour - I figured out how to create the replacement accessory and add a part, and inside the part named "Handle", added the mesh that the hat contains and the attachment. The only problem is the weld. All of the hats that I copy onto another person seems to get stuck in the same place by the neck area, and putting the accessory weld's C0 onto the new accessory's C0 does NOT work.
My script:(error will be in comment)
local plr = game.Players.LocalPlayer
local player = desiredPlayer
for _,v in pairs(player.Character:GetChildren()) do
if v:IsA("Accessory") then
local hat = Instance.new("Accessory", plr.Character)
hat.AttachmentForward = v.AttachmentForward
hat.AttachmentPos = v.AttachmentPos
hat.AttachmentRight = v.AttachmentRight
hat.AttachmentUp = v.AttachmentUp
local handle = Instance.new("Part", hat)
handle.Name = "Handle"
handle.CFrame = plr.Character.Head.CFrame
handle.Size = v.Handle.Size
handle.CanCollide = false
local mesh = Instance.new("SpecialMesh", handle)
mesh.MeshId = v.Handle.Mesh.MeshId
mesh.Offset = v.Handle.Mesh.Offset
mesh.Scale = v.Handle.Mesh.Scale
mesh.TextureId = v.Handle.Mesh.TextureId
for _,vv in ipairs(v.Handle:GetChildren()) do
if vv:IsA("Attachment") then
local HairAttachment = Instance.new("Attachment", handle)
HairAttachment.Name = "Attachment"
HairAttachment.Orientation = vv.Orientation
HairAttachment.Position = vv.Position
HairAttachment.Axis = vv.Axis
HairAttachment.SecondaryAxis = vv.SecondaryAxis
end
end
local AccessoryWeld = Instance.new("Weld", handle)
AccessoryWeld.Part0 = plr.Character["Head"]
AccessoryWeld.Part1 = handle
AccessoryWeld.C0 = v.Handle.AccessoryWeld.C0 -- everything works fine up until this point. the welds attach to the head, but NOT IN THE RIGHT POSITION!! I can't figure out any alternative to this!!
AccessoryWeld.C1 = v.Handle.AccessoryWeld.C1
end
end

2 comments
There is this function, but I haven't used it before: http://wiki.roblox.com/index.php?title=API:Class/Humanoid/AddAccessory
I am pretty sure, Because I use a system similar to this in my game to parent helmets to the head of players. You need to rotate the handle. Or move the handle. Because in my case everything follows the handle around. So moving or rotating the handle should solve the problem.