Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change a part's Y-axis rotation?

Asked by
Supint 60
8 years ago

I want to set B's rotation around the Y axis to A's rotation around the Y axis.

I don't want to change anything else about B's rotation. I have a headache and can't think right now, but I figure I'll have to do something with trigonometric functions and CFrame:components() or something.

Thanks.

1 answer

Log in to vote
2
Answered by 8 years ago

As it turns out, it's not terribly difficult! The code you're looking for is as follows:

part.CFrame = part.CFrame*CFrame.Angles(0, theta, 0)

As a quick reminder, CFrame.Angles(x, y, z)generates a rotated CFrame based on the input angles. Therefore, this code sets the part's CFrame to the composition of its original CFrame and a rotated CFrame based on the input angle.

Ad

Answer this question