PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Orientation

BasePart

Vector3

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.


Code Samples


Part Spinner

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

local part = script.Parent

local incr = 360/20

-- Rotate the part continually
while true do
	for deg = 0, 360, incr do
		-- Set only the Y axis rotation
		part.Rotation = Vector3.new(0, deg, 0)
		-- A better way to do this would be setting CFrame
		--part.CFrame = CFrame.new(part.Position) * CFrame.Angles(0, math.rad(deg), 0)
		wait()
	end
end