Weird snapping arm bug

hello! so i got a start on making my arm move with my gun. (trying to do something like breaking point). i ran into a problem. the arm kinda just snaps behind the character if that makes sense. i would appreciate any help! ty :smiley:

script:

	connection = rs.RenderStepped:Connect(function()

local char = game.Players.LocalPlayer.Character
		local rightshoulder:Motor6D = char.RightUpperArm.RightShoulder
		local leftshoulder:Motor6D = char.LeftUpperArm.LeftShoulder
		
		rightshoulder.C0 = CFrame.new(rightshoulder.C0.Position) * CFrame.Angles(0,math.deg(cam.CFrame.LookVector.X/-8),0,0)
		rightshoulder.C1 = CFrame.new(rightshoulder.C1.Position) * CFrame.Angles(math.deg(cam.CFrame.LookVector.Y/8),0,0)
	end)

vid:

This video explains this topic very well. Same exact math can be applied to this.