Rotate part using the World Y Axis

Hello
I have a Part, which I want to rotate around its own Pivot point in the World Y axis.
(like I can rotate it in Studio by a single World axis)
The following code does not produce the desired effect:

part:PivotTo(part:GetPivot()*CFrame.Angles(0, math.rad(angleNew), 0))

Can you recommend me a better approach?

Thank you in advance

You can do this, following the second option.

1 Like

My pivot point is not at the center of the part, but at one of the Part sides, so I need to include somehow the existing Part Pivot…
When I rotate around the Y axis in the studio, in addition to the rotation on Y, there is a change in position in X and Z.
Not sure how to achieve this effect in the code

Part.CFrame = CFrame.new(Part.Position) * CFrame.Angles(0, math.pi, 0)
This would rotate a part 180 degrees around the Y axis according to world space.

This does not take into account Part’s pivot point?

Pretty sure it should be something like this, not sure what you tried out via code.

part:PivotTo((CFrame.Angles(0, math.rad(angleNew), 0)*part:GetPivot().Rotation + part:GetPivot().Position)

Then you might need to add an offset CFrame or a dummy CFrame, similar to the tweening door example

This was before Pivot points were added, not sure if there is a simplified version now.

2 Likes

Thanks, that helped alot with my placement system! (I wondered how to replicate the rotation from Lumber Tycoon 2 with only two buttons)

1 Like