# Rotating a part around a pivot

I want to rotate a part let’s say 90 degrees around another part that acts as a pivot.

I found this post on the issue: How to rotate a part around a point while retaining the orientation of the part? though this person is trying to do something else they said in their post how to do what I want to do, just rotate the part around the pivot, and they said this: `Object.CFrame = Point * Rotation * Offset.`. now I tried to do this, but I don’t think I did it right so if someone could explain how to do it that is what I am looking for.

This is how I did it:

``````c.CFrame = CFrame.new(anchor.Position * 90 * math.sqrt(math.pow((c.Position.X-anchor.Position.X),2)+math.pow((c.Position.Y-anchor.Position.Y),2)+math.pow((c.Position.Z-anchor.Position.Z),2)))
``````

See if this helps:

I tried what it said in the post but it didn’t change anything. Sorry, I don’t really understand how CFrames work.
This is the new code:

``````local pivot = anchor.Position

local newpivot = CFrame.new(pivot)
local offset = newpivot:toObjectSpace(c.CFrame)
newpivot = newpivot * CFrame.Angles(0, anchor.Orientation.X, 0)
c.CFrame = newpivot * offset
``````