How can I get a part to rotate around a point? Say I have a brick 5 units in front of a point, how would I rotate it 180 degrees around the point while maintaining its distance?
Rotating around a point?
1 answer
CFrame
A simple implementation of CFrame.Angles will do the trick. CFrame.Angles returns a rotation with 3 given axes (X,Y,Z), in radians.
Radians overview
In case you don't know how radians work, I'll provide a quick overview. Radians are basically a different form of measurements for a circle (oppose to degrees). But, they can work the same way. An example of radians you're probably familiar with is Pi (3.14...) which represents half a rotation in radians. Therefore 2*Pi = 360 degrees, which is a full circle in radians (6.28...)
Anyway, with that out of the way, I'll give you an example:
local Point = CFrame.new(0,10,0) -- The point the object will rotate around
local Offset = CFrame.new(0,0,10) -- the offset of the part (distance from it)
local Object = Instance.new("Part",workspace)
Object.Anchored = true
while true do
-- Each iteration, we're making the Object's CFrame equal to the Point's CFrame, multiplied by the rotational CFrame, then again multiplied by the offset.
-- "math.rad" simply converts it's numeric argument to radians.
for i = 1,360 do
Object.CFrame = Point * CFrame.Angles(0,math.rad(i),0) * Offset
wait()
end
end
Note
I'm not gonna cover the entire CFrame library, so if you're not experienced in it, I suggest this wiki page: http://wiki.roblox.com/index.php?title=CFrame#Constructors
Hope this helped, let me know if you have any questions.
2 comments
thanks, that's exactly what I was looking for
Is it possible to apply this to a Tween? The problem I run into is that instead of rotating around the point, it just goes through it, when doing a 180 degree rotation.
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Script-wise, or otherwise? There are alternatives.
What exactly are you looking to do with this? I've got a few solutions for a few cases.
Would just writing a function for this be fine? I don't know what you want.