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

How can I make an object spin around another object?

Asked by 10 years ago

I want to make a sort of space hologram that includes our solar system and spinning planets. How would I be able to do this? I have all the planets laid out. I want them to spin around the center (Sun).

1 answer

Log in to vote
0
Answered by 10 years ago

Um. This is actually really simple but it depends. Laying them out is easy correct? But this is what I would do.

local part1 = sun
local part2 = world

while true do
    wait()
    for i = 1,360 do
        part2.CFrame = part1.CFrame
                     * CFrame.new(0,0,5)
                    * CFrame.Angles(0,math.rad(i),0)
    end
end

So what happens is, you put the world's cframe relative to the postion of the sun. This just makes it go in circles 5 studs away from the sun. I'm thinking of the top of my head so I'm not sure if it will orbit the sun or just spin in circles. It's one or the other.

Ad

Answer this question