Issue with welding

Code:

function WeldPart(Part0, Part1)
	local Weld = Instance.new("Weld")
	Weld.Part0 = Part0
	Weld.Part1 = Part1
	--Weld.C0 = Part0.CFrame:Inverse()
	Weld.C1 = Part1.CFrame:Inverse()
	Weld.Parent = Part0
	return Weld
end

function WeldPartsToSelf(PartToWeld)
	local Center = PartToWeld.Middle
	local OriginCF : CFrame = Center.CFrame
	local Z, X, Y = OriginCF:ToOrientation()
	
	for Index, Value in PartToWeld:GetChildren() do
		
		Value.Anchored = false
		
		if Value.Name == "Part" then
			Value:Destroy()
			continue
		end
		
		--if PartToWeld.Name == "UpperTorso" or PartToWeld.Name == "RightLowerLeg" then
		--	WeldPart(Center, Value)--.C0 = CFrame.Angles(X, Y, Z)
		--elseif Value ~= Center then
		--	WeldPart(Center, Value)
		--end
		
		WeldPart(Center, Value)
		
	end
end

image

I think it is because welds are relative to the part they are parented to and need to have relative Vector3’s to position them

1 Like