Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to Rotate Around a Point?

I have scoured the wikis far and wide. I have viewed the YouTube videos, but with no results. The question: How do I rotate an object around a certain point instead of its center? Sorry if this seems lazy, but trust me I have searched. ~yoman1776

2 answers

✓ Accepted answer

Utilize Object Space!

Here's an example:

local Center = CFrame.new(12, 165, 124)
local Part = workspace.Part
local i = 0
while true do
	Part.CFrame = Center:toWorldSpace(
		CFrame.new(
			Vector3.new(
				math.cos(math.rad(i)),
				0,
				math.sin(math.rad(i))
			)*10,
			Center.p
		)
	)
	--The syntax for this is <BASECFrame>:toWorldSpace(<CFrame in BASECFrame's Object Space>)
	--The inverse is then <BASECFrame>:toObjectSpace(<CFrame in World Space to Convert to BASECFrame's Object Space>)
	--I.e. Center:toObjectSpace(Part.CFrame)
	i = (i + 1)%360
end

Obviously, the math for this is harder if you want to rotate around an arbitrary axis, but the gist of it is there.

This discussion is preserved as it was. New answers, comments, and votes are closed.