Help making a part's orientation change with cframe

Hey!

I need to change just the cam.Orientation.Y property using CFrame, I tried this:

cam.CFrame = cam.CFrame * CFrame.Angles(0, math.rad(newCamOrientation - cam.Orientation.Y), 0)

But this change the cam.Orientation.X and cam.Orientation.Z properties too…

Try this:

cam.CFrame = cam.CFrame *
CFrame.Angles(
cam.Orientation.X, -- The Items Orientation on the X Axis
math.rad(newCamOrientation - cam.Orientation.Y), -- New Orientation on the Y Axis
 cam.Orientation.Z -- The Items Orientation on the Z Axis
)

Instead of Setting the Orientation to 0, It Sets it to the Orientation its already at

1 Like

Thank you! This worked, the only issue is that the part is looking exactly back, not forward, how can I make this part look forward again?

You may be able to flip it by using -var

Examples (Try them and see which ones work):

-math.rad(newCamOrientation - cam.Orientation.Y)

-newCamOrientation

-cam.Orientation.Y

Lets say you have a Variable name Apples and it has the Number 11, If you do -Apples, it will flip to -11

local Apples = 11

print(-Apples) -- prints "-11"
1 Like

I made many tests with what you said, but none of them worked, I think I will change this system, to see if it will work, thanks for your help!