I need help on Motor6D autowelder

Hi there! I made an autoFPS gun ViewModel welder for me but I’m wondering: How can I make that the gun when it weld it not do go in a big mess.

Lemme show you what I mean:
image
here is a photo of the gun after its welded

Here a photo before it is:
image

Here the script:
local module = {}

module.CreateViewModelAndWeld = function(WichArm, GunName)
	local ViewModel = script.Parent.Parent.ViewModel.v_viewmodel:Clone()
	ViewModel.Parent = workspace
	local GunModel = script.Parent.Parent.GunModel:WaitForChild(GunName):Clone()
	GunModel.Parent = ViewModel
	local Handle = GunModel.Handle
	local Right = ViewModel["Right Arm"]
	local Left = ViewModel["Left Arm"]
	print(WichArm)
	Handle.Anchored = false
	Handle.CanCollide = false

	
	local Motor6D = Instance.new('Motor6D')
	print('Done Creating Motor6D for the Handle')

	if WichArm == 'Right' then
		Motor6D.Parent = Right
		Motor6D.Part0 = Right
	elseif WichArm == 'Left' then
		Motor6D.Parent = Left

		Motor6D.Part0 = Left



	end

	Motor6D.Part1 = Handle

	ViewModel.Name = GunName..'_viewmodel'
	

	
	for i,v in pairs(GunModel.AnimatedPart:GetChildren()) do
		v.Anchored = false
		v.CanCollide = false
		local Motor6D2 = Instance.new('Motor6D')
		Motor6D2.Parent = Handle
		Motor6D2.Part0 = Handle
		Motor6D2.Part1 = v
		
		
	end
	
	for i,v in pairs(GunModel.OtherPart:GetChildren()) do
		v.Anchored = false
		v.CanCollide = false
		local Weld = Instance.new('Weld')
		Weld.Parent = Handle
		Weld.Part0 = Handle
		Weld.Part1 = v


	end
	print('Done Welding Part')
	

	
	

	

	
	
end

return module

everything works fine in my script there is no bug!

so I want it to stay in the same position as when it’s not welded how can I do that?

i forgot to say thank you in advance :smiley:

Moon Animator plug-in has a cleaner tool in it. It welds all the parts to the root part without changing its position/rotation. Try that out.

no what i mean is that im doing an auto welder script because i want to save time by not using other plugin

Well i found out how to do it by adding this little line of code!!:

Motor6D2.C0 = Motor6D2.Part0.CFrame:Inverse() * Motor6D2.Part1.CFrame and

Weld.C0 = Weld.Part0.CFrame:Inverse() * Weld.Part1.CFrame

(basically what I think it does is that it will make the cframe of the part the same as before)