# How do I make rotate around another part?

Q: How do I make a part rotate around another part?

Solutions I tried based off what I recently learned:

``````local MovePart = script.Parent
local targetPart = game.Workspace.TargetPart
local rot = 0

while true do
rot += 0.1
MovePart.CFrame = CFrame.new(Vector3.new(math.clamp(math.cos(rot), -1, 1) , 0 , math.clamp(math.sin(rot),-1, 1)), targetPart.Position)
wait(0.01)
end
``````

This is my goal:

2 Likes

Youâ€™re just forgetting a few thingsâ€¦
Remember to start at the `targetPart` position by adding itâ€™s position to the `MovePart` CFrame. Now just choose a distance and subtract the `MovePart` position by itâ€™s `LookVector` multiplied by `-distance`.

``````local MovePart = script.Parent
local targetPart = game.Workspace.TargetPart
local rot = 0
local distance = 13

while true do
rot += 0.1
MovePart.CFrame = CFrame.new(targetPart.Position + Vector3.new(math.clamp(math.cos(rot), -1, 1), 0, math.clamp(math.sin(rot),-1, 1)), targetPart.Position)
MovePart.Position -= MovePart.CFrame.LookVector * -distance
wait(0.01)
end
``````
6 Likes

Thank you, that helped. I didnt think to do that, im still trying to grasp the scope of what I can and not do in roblox studio.

1 Like