Now I have a question about so script…
– If I want to achieve a moon orbiting around a planet that is orbiting, how would I do this. I assume I need to somehow get the CFrame of the planet and make that the orgin?
u have to use trigonometry for it, mainly sin and cos. u first have to convert degrees to radians. then use sin and cos for x and y axis e.g
local radius = 5 --offset
local formula = math.rad(degree)
local x = math.sin(formula)*radius
local z = math.cos(formula)*radius
Part:PivotTo(Origin * CFrame.new(x, 0, z))
local alpha = 0
local radius = 5 --offset
local Origin = CFrame.new()
local Part = workspace.Planets.Mercury
while true do
alpha += .5
local formula = math.rad(alpha)
local x = math.sin(formula)*radius
local z = math.cos(formula)*radius
Part:PivotTo(Origin * CFrame.new(x, 0, z))
end
Here, I apologize for not elaborating further. Here’s and image describing what I am trying to accomplish. The Bigger Object will go by Mercury while the smaller will go by Moon.
u have to adjust the code accordingly to ur workspace hierarchy. U can just put the script in serverscriptservice and reference all the objects from there
Question, I’m still having a little trouble with this. Would you be able to contact me on discord for easier communication? If you’re not comfortable with this, that’s completely okay!