Viewmodel constantly conflicts with motor6d/welds

Whenever I go into first person, then I start equipping a weapon I made that is welded, eventually my viewmodel causes my entire character to be frozen and move in a random direction slowly. The tool works by adding a motor6d to the character’s arm in 3rd person, then adding adding a motor6d to the viewmodel arm when you are in first person.

below is the viewmodel script

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")
local torso = char:FindFirstChild("Torso")

local animator = hum:FindFirstChild("Animator")

local rightshoulder = torso:FindFirstChild("Right Shoulder")
local leftshoulder = torso:FindFirstChild("Left Shoulder")

local rs = game:GetService("RunService")
local uis = game:GetService("UserInputService")
local ps = game:GetService("PhysicsService")
local mouse = plr:GetMouse()

local springmodule = require(game.ReplicatedStorage.Modules.Utility.SpringModule)
local sway = springmodule.new()

local AnimationConnection


local cam = game.Workspace.CurrentCamera
if cam:FindFirstChild("Viewmodel") then
	cam.Viewmodel:Destroy()
end

local loadedAnimations = {}



-- Viewmodel Creation
local viewmodel = char:Clone()
viewmodel.Parent = cam
viewmodel.Name = "Viewmodel"

local viewmodelAnimator = viewmodel.Humanoid.Animator
local viewmodelHumanoid = viewmodel.Humanoid

-- Setting up properties
viewmodelHumanoid.BreakJointsOnDeath = false
viewmodelHumanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
viewmodelHumanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
viewmodel.Head.Anchored = true
viewmodel.PrimaryPart = viewmodel.Head

local viewmodelShirt = viewmodel:FindFirstChild("Shirt") or Instance.new("Shirt")


if AnimationConnection then
	AnimationConnection:Disconnect()
end


for _, v in pairs(viewmodel:GetDescendants()) do
	if v:IsA("BasePart") then
		v.CastShadow = false
		v.CanCollide = false
		v.Massless = false
		v.CollisionGroup = "Viewmodel"

		local partName = v.Name:lower()
		if partName:match("leg")  then
			v:Destroy()
		elseif not partName:match("arm") then
			v.Transparency = 1
		end
		
		if v.Name == "Holster" then
			v:Destroy()
		end
	elseif v:IsA("Decal") or v:IsA("Accessory") or v:IsA("LocalScript") then
		v:Destroy()
	end

end

AnimationConnection = animator.AnimationPlayed:Connect(function(Track)
	if not loadedAnimations[Track] then
		local Viewanim = viewmodelAnimator:LoadAnimation(Track.Animation)
		loadedAnimations[Track] = Viewanim
	end
end)

local function UpdateAnim()
	for CharAnim, Anim in pairs(loadedAnimations) do
		if CharAnim.IsPlaying ~= Anim.IsPlaying then
			if CharAnim.IsPlaying then
				Anim:Play(0.100000001,1)
			else
				Anim:Stop()
			end
		end
		
		if not Anim.IsPlaying and CharAnim.IsPlaying then
			Anim:Play()
		end
		Anim.TimePosition = CharAnim.TimePosition
		Anim.Looped = CharAnim.Looped
	end
end

-- First Person
rs.RenderStepped:Connect(function(dt)
	for _, v in pairs(char:GetDescendants()) do
		if v:IsA("BasePart") then
			if v.Name == "Head" and v.LocalTransparencyModifier == 1 then
				hum:AddTag("InFirstPerson")
				UpdateAnim()
				
				for _, v in pairs(viewmodel:GetDescendants()) do
					if v:IsA("BasePart") then
						v.CanCollide = false
					end
				end
				
				local updatedsway = sway:update(dt)
				local Delta = game.UserInputService:GetMouseDelta()
				sway:shove(Vector3.new(-Delta.X/490, Delta.Y/490, 0))
				
				viewmodel:PivotTo(cam.CFrame * CFrame.new(0,0,-0.6) * 
					CFrame.new(updatedsway.X,updatedsway.Y,0)
				)
				
				-- Shirt and bodycolor after death
				viewmodelShirt.Parent = viewmodel
				local charshirt = char:FindFirstChild("Shirt")
				if charshirt  then
					viewmodelShirt.ShirtTemplate = charshirt.ShirtTemplate
				end
				
				for _, v in pairs(viewmodel:GetDescendants()) do
					if v:IsA("BasePart") and v.Name ~= "Holster" then
						v.Color = char[v.Name].Color
					end
				end
				
			elseif v.Name == "Head" and ( v.LocalTransparencyModifier ~= 1) then
				hum:RemoveTag("InFirstPerson")
				viewmodel:FindFirstChild("Right Arm").Transparency = 1
				viewmodel:FindFirstChild("Left Arm").Transparency = 1
				
			end
		end
	end
end)