I have myself a situation where I have a CFrame of a BodyGyro which has to be rotated on the world Y axis (relative to the world space).
I know that CFrame * CFrame rotates relative to the object space not world space, so I am a bit puzzled on how to do what I want.
So far I have tried:
vector = gyro.CFrame:vectorToObjectSpace(rotation)
gyro.CFrame = gyro.CFrame * CFrame.Angles(vector.x, vector.y, vector.z)
rotation - a vector with the desired rotation in radians vector - variable to hold rotation converted to object space
The problem is that the code above seems to be very unstable and fails whenever I exceed a rotation of 30 degrees on Z axis. It starts to give me incorrect rotation with +- 30 degree difference from what it should be.
EDIT: I have also tried this:
gyro.CFrame=(rotation * (gyro.CFrame - gyro.CFrame.p)) + gyro.CFrame.p
Wierdly enough, it doesn't rotate along the world axis at all. If I compare to rotating a part via setting its Orientation, it doesn't even come close to how it should be rotated.
But now I finally figured it out: every time you rotate a part the rotation has to be incremented for it to properly rotate. Otherwise it is just constantly rotating a part along the set rotation, but not axis.

4 comments
i recently answered this so friendly duplicate moderation, no offense
If you answered it, can you please point me to the question where I can find your answer?
BTW Part.CFrame=(rot*(Part.CFrame-Part.CFrame.p))+Part.CFrame.p doesn't work for me
Here’s the question cabbler was talking about : https://scriptinghelpers.org/questions/56463