How do I get the Rotation/Orentation of a CFrame?

I need to get either the Rotation or Orientation of a CFrame for a game (in a Vector3), anyone know how?

local orientation = basePart.CFrame.Rotation

or

local orientation = basePart.CFrame - object.CFrame.Position

EDIT @atfdaj in that case you might be looking for this:

1 Like

I forgot to mention it needs to be in the form of a Vector3

local orientation = basePart.Orientation

BELOW IS FROM THE ROBLOX WIKI (too lazy to ss)

Orientation

Vector3

HIDDEN

NOT REPLICATED

READ PARALLEL

The Orientation property describes the part’s rotation in degrees around the X, Y and Z axes using a Vector3. The rotations are applied in Y → X → Z order. This differs from proper Euler angles, and is instead Tait–Bryan angles which describe yaw, pitch and roll. It is also worth noting how this property differs from the CFrame.Angles() constructor, which applies rotations in a different order (Z → Y → X). For better control over the rotation of a part, it is recommended that BasePart.CFrame is set instead.

When setting this property any Welds or Motor6Ds connected to this part will have the matching C0 or C1 property updated and to allow the part to move relative to any other parts it is joined to.

WeldConstraints will also be temporarily disabled and re-enabled during the move.

Code Samples

This code sample rotates a part continually on the Y axis.

Part Spinner


local part = script.Parent

local INCREMENT = 360 / 20

-- Rotate the part continually
while true do
	for degrees = 0, 360, INCREMENT do
		-- Set only the Y axis rotation
		part.Rotation = Vector3.new(0, degrees, 0)
		-- A better way to do this would be setting CFrame
		--part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, math.rad(degrees), 0)
		task.wait()
	end
end
local ori = Vector3.new(cf:ToEulerAnglesXYZ())
1 Like