WeldConstraints resetting offset when used on players

I am making an armor system for my game, and I am using a 3-part model for the visual part of the armor. For the most part, the cuirass/chestplate works fine, keeping the offset I give it in the code. However, the welds on the pauldrons are for some reason resetting the offset (picture shows unintended behavior, where the top of the arm clips through the pauldrons)

I’ve tried a few things and narrowed it down to something with the welds, as if I comment out the weld code for the pauldrons they do appear where they would with the offsets. The weird thing is that the code for the cuirass/chestplate welding is the EXACT SAME as the code for the pauldrons.

local function EquipPlayerArmor(ItemID:number, char:Model)
	-- these first lines are probably irrelevant, but it gives some context to what is going on.
	local ArmorName = IDConversions.ItemIDToString(ItemID)
	local ArmorModel:Model
	
	for i, v in pairs(char:GetChildren()) do
		if v.Name == "ArmorModel" then
			v:Destroy()
		end
	end
	
	for i, v in pairs(ServerStorage.ArmorModels:GetChildren()) do
		if v.Name == ArmorName then
			ArmorModel = v:Clone()
		end
	end
	
	-- relevant code starts here
	if ArmorModel then
		ArmorModel.Cuirass.CFrame = char.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-90), 0)
		ArmorModel.Cuirass.Position += Vector3.new(0,0.08,0) -- this is the offset for the cuirass/chestplate (i know for a fact this works)
		
		ArmorModel.LeftPauldron.CFrame = char.LeftUpperArm.CFrame * CFrame.Angles(0, math.rad(-90), 0)
		ArmorModel.LeftPauldron.Position += (Vector3.new(0,0.35,-0.1) * char.PrimaryPart.CFrame.LookVector) -- this is the offset for the left pauldron (definitely the wrong numbers, but that's not the point of the post)
		--ArmorModel.LeftPauldron.Anchored = true
		
		ArmorModel.RightPauldron.CFrame = char.RightUpperArm.CFrame * CFrame.Angles(0, math.rad(-90), 0)
		ArmorModel.RightPauldron.Position += (Vector3.new(0,0.35,0.1) * char.PrimaryPart.CFrame.LookVector) -- this is the offset for the right pauldron (definitely the wrong numbers, but that's not the point of the post)
		--ArmorModel.RightPauldron.Anchored = true
		
		-- cuirass weld code
		local CuirassWeld = Instance.new("WeldConstraint")
		CuirassWeld.Parent = ArmorModel.Cuirass
		CuirassWeld.Part0 = ArmorModel.Cuirass
		CuirassWeld.Part1 = char.UpperTorso
		
		-- left pauldron weld code
		local LeftPauldronWeld = Instance.new("WeldConstraint")
		LeftPauldronWeld.Parent = ArmorModel.LeftPauldron
		LeftPauldronWeld.Part0 = ArmorModel.LeftPauldron
		LeftPauldronWeld.Part1 = char.LeftUpperArm
		
		-- right pauldron weld code
		local RightPauldronWeld = Instance.new("WeldConstraint")
		RightPauldronWeld.Parent = ArmorModel.RightPauldron
		RightPauldronWeld.Part0 = ArmorModel.RightPauldron
		RightPauldronWeld.Part1 = char.RightUpperArm

		ArmorModel.Parent = char
		ArmorModel.Name = "ArmorModel"
	end
end

I’ve swapped the part0/part1 on the weldconstraints, changed the offsets to see if they were wrong, disabled the welding code to see if the offsets were actually applying before the weld (they were), and searched for anything relevant on here. Any help is appreciated, thank you for reading.

Welds need their C0 and C1 set for the offset, otherwise they center on the Part0 and Part1’s Positions. See the link for a better description.

You shouldn’t set the CFrames for them the way you are.

Just weld the UpperRightArm (Part0) to the RightPauldron (Part1). This gets it placed with the welds centered on Part0 and Part1.
Leave the C0 CFRame alone.
Set the C1 CFrame to align the to where you want the Pauldron positioned and rotated.

1 Like

This did work, thank you! One thing I should probably note for anyone else with this issue is I made the UpperRightArm Part1 and the RightPauldron Part0, though I still used the C1 CFrame and it worked fine.

Yeah, either way works.
I just find it’s easier for me if I make the 1st Parent Part the Part0 to keep it more organized in my mind.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.