Animation causing axis to not be correct

  1. What do you want to achieve? The waist and head move up and down according to the camera

  2. What is the issue? The arms seem to be rotating based off of the left arm, which I need it to be rotated based off of the center. I believe this is caused due to the fact that the animation makes the player rotated a little bit when holding the gun. https://gyazo.com/ae7bf6a553dbb27e95f3200bd310f637

  3. What solutions have you tried so far? Looked on devforum, couldn’t find any solutions.



local neckC0 = CFrame.new(0, 0.8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
game.ReplicatedStorage.ArmsEvent.OnServerEvent:Connect(function(player,Camera,RootCFrame,CameraCFrame,CameraSubject)
	if player.Character ~= nil then
		local body = player.Character.HumanoidRootPart
		if player.Character.Head.Neck ~= nil then 
			if player.Character.UpperTorso:FindFirstChild("Waist") ~= nil then
				local neck = player.Character.Head.Neck;
				local waist = player.Character.UpperTorso.Waist;
				local theta = math.asin(CameraCFrame.LookVector.y)
				local camera_angle = math.atan2(CameraCFrame.LookVector.X, CameraCFrame.LookVector.Z)
				local body_angle = math.atan2(body.CFrame.LookVector.X, body.CFrame.LookVector.Z)
				local theta2 = (camera_angle-body_angle)%(2*math.pi)

				if theta2 > math.pi/2 and theta2 < math.pi*1.5 then
					theta2 = math.pi-theta2
				end
				neck.C0 = neckC0 * CFrame.Angles(theta*0.5, -theta2, 0);
				CFrame.new()
				waist.C0 = waistC0 * CFrame.Angles(theta*0.5, 0, 0);
			end
		end
	end

	end)


game.ReplicatedStorage.UnArmsEvent.OnServerEvent:Connect(function(player,Camera,RootCFrame,CameraCFrame)
	local Character = player.Character
	local Neck = Character:FindFirstChild("Neck", true)

	Neck.C0 = CFrame.new(0, 0.8, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
	Character.RightUpperArm.Joint.C0 = CFrame.new(.9,.63,0)
	Character.LeftUpperArm.Joint.C0 = CFrame.new(-.9,.63,0)
	Character.UpperTorso.Waist.C0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
end)