Welding Primary Part to a Players Head

  1. What do you want to achieve? Keep it simple and clear!
    I want to weld a snorkle model with multiple mesh parts in it to a players head ( and be able to rotate it to look right on their head )

  2. What is the issue? Include screenshots / videos if possible!
    When i try welding it to the players head, it just parents to the character and sits in workspace

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Looked on the dev forum similar topics, but other people don’t seem to be having this issue

local head = plr.Character["Head"]
local snorkle = game:GetService("ReplicatedStorage")["Snorkle"]:Clone()
snorkle.Parent = plr.Character
local primarypart = snorkle["PrimaryPart"]
local weld = Instance.new("WeldConstraint", head) --Could also use a Motor6D, or likewise
snorkle:SetPrimaryPartCFrame(plr.Character.Head.CFrame * CFrame.new(0, 0, 0.1))
--weld.C0 = CFrame.new() * CFrame.Angles(0, 0, 0)
--weld.C1 = CFrame.new() * CFrame.Angles(0, 0, 0)
weld.Part0 = head
weld.Part1 = primarypart
		
snorkle.Parent = plr.Character

The angles part is there for later incase I need to rotate it to look right on the players head.
This is a look at how the model is designed:
image

It just doesn’t seem to weld onto the players head, I also tried normal Welds instead of Weld constraints and it did not work. I used similar code for singular mesh flippers and it worked, so I don’t know what the issue is. Any ideas or help will be appreciated

Edit: The arguements for plr and stuff are correct, and there’s no errors in console

maybe set the mesh/part to the players head

Part.Position = Player.Head.CFrame

woulden’t this line essentially do the same thing?

maybe the offset is too much

snorkle:SetPrimaryPartCFrame(plr.Character.Head.CFrame.X, plr.Character.Head.CFrame.Y, plr.Character.Head.CFrame.Z + 0.1,))

same issue occured when i tried this

I had written code for another topic that should also work for you.

Code:

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

Just make sure the accessory isn’t welded prior, and then apply the weld after using this function.

interesting, i’ve never seen that, i’ll try it out later today and see if it works

local head = plr.Character["Head"]
			local snorkle = game:GetService("ReplicatedStorage")["Snorkle"]:Clone()
			snorkle.Parent = plr.Character
			local primarypart = snorkle["PrimaryPart"]
			--local weld = Instance.new("WeldConstraint", head) --Could also use a Motor6D, or likewise
			--snorkle:SetPrimaryPartCFrame(plr.Character.Head.CFrame.X, plr.Character.Head.CFrame.Y, plr.Character.Head.CFrame.Z + 0.1)
			--weld.C0 = CFrame.new() * CFrame.Angles(0, 0, 0)
			--weld.C1 = CFrame.new() * CFrame.Angles(0, 0, 0)
			local weld = Instance.new("WeldConstraint", head)
			weld.Part0 = head
			weld.Part1 = primarypart
			
			local 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
			
			Move_Part_By_Attachments(primarypart, weld.Part0, weld.Part1)
			
			snorkle.Parent = plr.Character

im a little confused on the attachment part, do i need to insert attachments into the characters head or something for this to work? i’ve never used attachments before, do you mean welds or is there actually instances called attachments

This thread outlines one way you could attach your snorkeling model to a character’s head.

Another way would be by taking the head of a rig that all characters use as a template (do this in studio) and then position your snorkeling model on that template head, then parent the template head to your model and change your model structure so that everything is welded to the template head, because it will act as the PrimaryPart of your snorkeling model. This way, you can easily do:

local snorkelingModel = PATH_TO_MODEL:Clone()
snorkelingModel:PivotTo(someCharacter.Head.CFrame)
-- some code to weld the model to the character's head here using the primarypart of the snorkeling model
snorkelingModel.Parent = someCharacter

You use attachments instead of parts, just like the case in Accesories (e.g. HatAttachment in handle and char head).

I found the issue with my code:

snorkle:SetPrimaryPartCFrame(plr.Character.Head.CFrame * CFrame.new(0, 0, 0.1))

Actually was an error, somehow it coulden’t cast the direction once i changed it to primarypart.CFrame = head.CFrame it worked, but thanks for all the assistance!

Edit: future code incase anyone is interested:

local head = plr.Character["Head"]
			local snorkle = game:GetService("ReplicatedStorage")["Snorkle"]:Clone()
			
			local primarypart = snorkle:WaitForChild("PrimaryPart")
			local weld = Instance.new("Weld", head) --Could also use a Motor6D, or likewise
			primarypart.CFrame = head.CFrame
			--weld.C0 = CFrame.new() * CFrame.Angles(0, 0, 0)
			--weld.C1 = CFrame.new() * CFrame.Angles(0, 0, 0)
			weld.Part0 = head
			weld.Part1 = primarypart
			snorkle.Parent = plr.Character
1 Like