CFrame:ToOrientation returns number for some reason

I’m currently trying to modify a rocket I made so that it points in the direction of the first player it detects. I’m using this line of code to get an orientation I can assign to the rocket since I want to keep its position:

local targetOri = CFrame.lookAt(missile.Position, target.Position):ToOrientation()

At first it seemed pretty logical, but while testing I keep getting the same error; the console complains that I’m giving it a number instead of a Vector3, and sure enough, when I print the variable targetOri to the console it shows me values such as “-0.00022263606660999358” which, to my knowledge, are completely meaningless and useless. Am I using ToOrientation() incorrectly? Is there any alternative method I should be doing instead?

The function works a bit differently rather than accessing .Orientation property

It would be like this which uses returns multiple results:

local oriX, oriY, oriZ = CFrame.lookAt(missile.Position, target.Position):ToOrientation()
--also you would have to convert these from radians to degrees using math.deg or 180/math.pi

However I would recommend working directly with CFrames example changing orientation property.
No need for any further angle conversions just use the rotation matrix as is.

local goalRotation = CFrame.lookAt(missile.Position, target.Position).Rotation
part.CFrame = goalRotation + part.Position
1 Like