CFrame:ToOrientation not working as expected

I want to be able to get the orientation of the CurrentCamera through a LocalScript and this is what I have tried:

local camOrientation

while true do
	camOrientation = game.Workspace.CurrentCamera.CFrame:ToOrientation()
	print(camOrientation.X..", "..camOrientation.Y..", "..camOrientation.Z)
	task.wait()
end

It gives me this error:

  12:59:07.605  StarterPlayer.StarterPlayerScripts.Test:5: attempt to index number with 'X'  -  Client - Test:5
Stack Begin
  12:59:07.606  Script 'StarterPlayer.StarterPlayerScripts.Test', Line 5  -  Studio - Test:5
Stack End

What do I do? I think I’ve formatted it right. The docs say that CFrame:ToOrientation returns a Vector3. Thanks in advance!

Edit: This is in Game/StarterPlayer/StarterPlayerScripts

The docs say that ToOrientation returns “number” which is actually a tuple of 3 angles in radians :slight_smile:
image

:ToOrientation() doesn’t return a vector, but instead 3 independent variables, so you have to do
local x, y, z = Cframe:ToOrientation()
it’s incredibly stupid, but that’s how it is

3 Likes

Thanks a lot Trump
I knew I could count on you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.