Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to rotate a part around a moving point?

Asked by 4 years ago

I'm trying to build a solar system and I have managed to make the moon follow the Earth but it won't spin around it. I've messed around with the script for half an hour now and need some help to figure it out.

local Earth = script.Parent.Earth

local Point = CFrame.new(Earth.Position)
    local Offset = CFrame.new(0,0,40)

    local Object = script.Parent.Moon
    Object.Anchored = true

    while true do
Point = CFrame.new(Earth.Position)

for i = 1,1 do
    Object.CFrame = Point * CFrame.Angles(0,math.rad(i),0) * Offset
    wait()
    end
end
0
for i=1, 1 do User#6546 35 — 4y

Answer this question