:ToOrientation() not working as it is supposed to be

Hello,
CFrame:ToOrientation() is not working as it is supposed to be.

local mo = game.Players.LocalPlayer:GetMouse()
local cha = game.Players.LocalPlayer.Character
mo.Button1Down:Connect(function()
    local x,y,z = CFrame.new(cha.HumanoidRootPart.Position,mo.Hit.p):ToOrientation()
    print(y)
    local rotation = y*90
    game.ReplicatedStorage.Events.RemoteEvent:FireServer(CFrame.new(mo.Hit.p.X,cha.HumanoidRootPart.Position.Y,mo.Hit.p.Z)*CFrame.fromEulerAnglesXYZ(0, math.rad(rotation), 0))

end)

As you can see in the video, it is fine for the first 90 degrees (first quarter) but once it approaches 180 degrees, it should face 180 degrees but it instead faces 270 degrees and the next quarter, it restarts again from the start of the second quarter??

- Br, iSyriux

math.deg(y),

3 Likes