How can I get the rotation vector of a CFrame?

So basically, I think i’m looking at this the wrong way and it probably can be solved very easily but, I’m trying to rotate a part based on the camera’s rotation. Which is very simple, but i’m having trouble rotating it with a custom position while still rotating based on the camera.

Here’s a simple version of the script:

local CustomVector = workspace.CustomVectorPart;

while wait() do
	local rotation = workspace.CurrentCamera.CFrame - workspace.CurrentCamera.CFrame.p;--< Basically This Works Find If I Want To Reset The Position To The Worlds Origin
	
workspace.Part.CFrame = CFrame.new(CustomVector.p) * rotation--< The problem with this is since rotations position resets to 0,0,0 . Multiplying it will always set 0,0,0 to the position

end

Is there any possible way I could get the rotation vector separately? I’ve tried using CFrame.angles but rotation.X is just the same 0x Position, not the “lookAt” vector. I know this is probably stupid, but it’s starting to annoy now.

To get the x,y, and z of a cframe’s rotation vector (in radians) you get a tuple of all 3 from cframe:ToEulerAnglesXYZ()
Ex: local x,y,z = cframe:ToEulerAnglesXYZ()

ps. while wait() do loops break constantly in my experience

3 Likes

Let me inform you on the terminology. There is no rotation vector, but there is a rotation component that is consisted of three different vectors.

Anyways:

You can do local x, y, z = CFrame:ToOrientation()

1 Like

I’ve actually tried ToEulerAngles and ToOrientation but I implemented them in a completely different way. Thank you

1 Like