CFrame.Angles problem

Okay I’ve figured it out!

If you want to “Set” the Rotation of the CFrame you first sets it’s Rotation to 0,0,0 then do * CFrame.Angles()

like this:

local part = part -- part with any position and any rotation
-- example
-- part.Position = (10,5,8)
-- part.Orientation = (12,73,23)

local CFrameWithoutRotation = CFrame.new(part.Position) -- or part.CFrame.Position

local CFrameWithSetRotation = CFrameWithoutRotation * CFrame.Angles(math.rad(90,math.rad(0),math.rad(0))

-- set it to the part
part.CFrame = CFrameWithSetRotation

--result
--part.Position = (10,5,8)
--part.Orientation = (90,0,0)

or you can simply write it

part.CFrame = CFrame.new(part.CFrame.Position) * CFrame.Angles(math.rad(90),0,0)

Think of cf * CFrame.Angles() as “adding” instead of multiplying because that’s really what’s it’s doing conceptually. Multiplying CFrames do not behave like multiplying in normal math.

3 Likes

Thanks a lot! The script you provided is working perfectly!

1 Like

No problem :+1: I was so excited that I figured it out because I had the same question as you for the longest time :sweat_smile:

1 Like