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

Rotate a Part using Radians

Rotate a Part using Radians

Jun 23 2018, 10:23 AM PST

Problem

You want to rotate a part in radians.

Solution

Use the CFrame.Angles function and multiply it by the CFrame position.

local part = Instance.new('Part')
part.Parent = Workspace
part.Anchored = true
part.CFrame = part.CFrame * CFrame.Angles(0, math.pi, 0)

Discussion

To get a rotated CFrame we take the position and multiply it by an Angle component. We get this by calling the CFrame.Angles function. Here we just want to rotate the part, so we want the same position so we just use part.CFrame and multiply it by CFrame.Angles(0, math.pi, 0). We’re rotating in radians here on the Y-axis by math.pi which is equal to 180 degrees.

Tags:
  • math
  • rotate
  • movement