I’m trying to get the radians of each axis so I can clamp them, but when I do so, I get (0,0,0). However, when I set the part’s CFrame to the one created by :fromMatrix(), it gives me the desired radians. The script is making the part be flushed with the base of the other part. See below:

local part = script.Parent
function detectGround(p,ignore)
local ray = Ray.new(p.Position,-p.CFrame.UpVector.Unit*500)
local hitPart, hitPosition,normal = workspace:FindPartOnRay(ray, ignore)
if hitPart then
return normal,hitPosition
end
end
local normal, hitpos = detectGround(part,part)
if not normal then return end
local rCF = CFrame.lookAt(part.CFrame.Position,part.CFrame.Position+part.CFrame.LookVector)
local NormalCFrame = CFrame.fromMatrix(hitpos+normal,rCF.lookVector:Cross(normal),normal,-rCF.lookVector) --gets the NormalCFrame that is flush with the part
local x,y,z = NormalCFrame:ToOrientation() --the radians of Normal CFrame
print(math.deg(x),math.deg(y),math.deg(z)) --Gives (0,0,0)
part.CFrame = NormalCFrame --setting CFrame of the part to NormalCFrame
x,y,z = part.CFrame:ToOrientation() --the radians of the part's CFrame now
print(math.deg(x),math.deg(y),math.deg(z)) --Gives (~22.5,0,0), which is what I'm looking for...
I don’t really understand why it is doing this… I’ve tried a lot of things, yet none of them seem to be working out, and the only solution as of now is to create a “dummy” part and read the CFrame of that when it is set to NormalCFrame.