How to make archandle rotation motor6d in dummy rig properly

I am currently working on a game project called “Animation Maker” but I have a problem with the archandle, that is, every time I rotate the archandle with the motor6d, it goes in different directions. I have spent hours trying to fix it but it doesn’t work.

Code:

function round(number)
	return math.floor((number /1) * 1) 
end

function AngleFromAxis(axis, r)
	local relativeAngle = math.rad(round(math.deg(r)))
	
	if axis == Enum.Axis.X then
		return {relativeAngle, 0, 0}
	elseif axis == Enum.Axis.Y then
		return {0, relativeAngle, 0}
	elseif axis == Enum.Axis.Z then
		return {0, 0, relativeAngle}
	end
end

local function CreateHandles(Player: Player, Handle: Handles, item: basepart)

	local Rotation

	if not item then
		return
	end
	
	if Handle == "Rotation" then

		local Handler = ReplicatedStorage.Handles.ArcHandle:Clone()
		Handler.Parent = Player.PlayerGui

		if item:IsA("Model") then
			Handler.Adornee = item.PrimaryPart
		else
			Handler.Adornee = item
		end
								
		for i, v in pairs(item.Parent:GetDescendants()) do
			if v:IsA("Motor6D") and v.Part1 == item then
				print("Motor6D: "..tostring(item))
				item = v
			end
		end
		
		Handler.MouseButton1Down:Connect(function()
			if item:IsA("Model") then
				Rotation = item:GetPivot()
			elseif item:IsA("Motor6D") then
				Rotation = item.C1
			else	
				Rotation = item.CFrame
			end
		end)

		Handler.MouseDrag:Connect(function(axis, relativeAngle, delta)
			if item:IsA("Model") then
				item:PivotTo(Rotation * CFrame.Angles(unpack(AngleFromAxis(axis, relativeAngle))))
			elseif item:IsA("Motor6D") then
				item.C1 = Rotation * CFrame.Angles(unpack(AngleFromAxis(axis, relativeAngle)))		
			elseif item:IsA("BasePart") then
				item.CFrame = Rotation * CFrame.Angles(unpack(AngleFromAxis(axis, relativeAngle)))
			end
		end)
	end	
end

Video:

Cant you do CFrame:Inverse()
Also you seem to not understand how CFrame.fromEulerAnglesXYZ() works (CFrame.Angles) so i recomend you to use CFrame.fromEulerAnglesYXZ() becouse its more understandable to human.
?

I have used CFrame:Inverse() before, but the result is no different.