The hat places on the character right and can be removed, however, the hat isn't positioned correctly and is inside of the head. Here's my code:

function click()
	local player = game.Players.LocalPlayer
	local playername = player.Name
	local character = game.Workspace:FindFirstChild(playername)
	local children = character:GetChildren()
	
	--Hat Equips Here
	
	local hat3 = Instance.new("Hat")
	local part3 = Instance.new("Part")
	local hatweld = Instance.new("Weld")
	hatweld.Name = "AccessoryWeld"
	hatweld.Parent = hat3
	hatweld.Part0 = part3
	hatweld.Part1 = character:FindFirstChild("Head")
	hatweld.C0 = CFrame.new(0,0.125,-0.325)
	hat3.Name = "blondebun"
	part3.Parent = hat3
	part3.Position = character:FindFirstChild("Head").Position
	part3.Name = "Handle"
	part3.formFactor = 0
	part3.Size = Vector3.new(1, 1, 1)
	part3.BottomSurface = 0 
	part3.TopSurface = 0 
	part3.Transparency = 0
	part3.Locked = false
	part3.Anchored = false
	game.Lighting.meshes.blondebun:Clone().Parent = part3
	hat3.Parent = character
	hat3.AttachmentPos = Vector3.new(0,0.125,-0.325)
end

script.Parent.MouseButton1Click:connect(click)

Must I do something with the weld attachment point / CFrame or what? I assume I have to CFrame it onto the head, but how do I place it in the same position as the AttachmentPos Vector?

3 comments

0
  1. Lighting is not meant for storage. 2) Stop doing useless physics calculation that you don't want nor was intended.
0
  1. I can store whatever I want, wherever I want, especially if I'm not using that section. 2) It just helps me be more specific.