Planet "orbit" script not working as intended

I’m just trying to make my planets orbit the Sun. Pretty simple, right?

Well, as usual, I’ve found a way to take something that should be simple and make it unnecessarily complicated. For some reason, my planet seems to completely ignore distance and instead stays in the center of the Sun:

    local i = 0 
	local dist = des[x].Distance.Value --How far the planet is from the star.
	local spd = des[x].Speed.Value --How fast the planet orbits.
	local angle = 90--des[i].Angle.Value --how far the planet is tilted in its orbit.
	while true do 
		i=i+1 
		wait() 
		des[x]:SetPrimaryPartCFrame(point*CFrame.fromEulerAnglesXYZ(angle,i*spd,0)*CFrame.new(0,0,dist * 10000))
	end

(des[x] is the planet and point is the Sun)

As you can tell, I’ve tried multiplying the distance by ungodly amounts to no avail. It’s like my math is completely ignoring distance altogether. Does anyone see something I’m doing wrong?

1 Like

Have you checked to make sure distance isn’t 0?

1 Like

Wow, I checked distance and it turns out I was using a Vector3Value the whole time… Oops.

Another happy day of programming.

1 Like

Lol. We all make dumb mistakes, yesterday I spent like half an hour trying to figure out why

function FunctionName() do

end
end

needed two ends before I realized I had typed do.

4 Likes