Need help setting an object in a specific location for orbiting a sphere

I’m making a cloud system which orbits around a planet.

I made it so it orbits the planet in a slow trajectory, however I want it to spawn randomly anywhere because its starting position is only at one unknown point, which I have no idea on how to achieve this.

local reference = CFrame.Angles(math.rad(45), 0, math.rad(45)) 
local radius = script.Parent.PlanetRadiusSize.Value + 500
local angle = 0
local speed = 0.002
	
game:GetService("RunService").Heartbeat:Connect(function(dt)
		
    angle = angle + speed * dt
	cloudparticle.Position =
	core.Position + reference
	* Vector3.new(radius * math.cos(angle), 0, radius * math.sin(angle))
		
end)

2 Likes

You could add a XOffset and a YOffset in math.cos(angle)
it would look a bit like math.cos(angle+XOffset)...

The XOffset and YOffset could be randomized via math.random()*360 or predetermined:

local predeterminedXOffsets = {--list of possible xoffsets}
local predeterminedYOffsets = {--list of possible yoffsets}

local XOffset = predeterminedXOffsets[math.random(1,#predeterminedXOffsets]
local YOffset = predeterminedYOffsets[math.random(1,#predeterminedYOffsets]
...

or if you want to use randomized completely:

local XOffset = math.random()*360
local YOffset = math.random()*360
...

Hope that helps!

1 Like

That’s weird, because instead it seems like it’s going up and down.

Wait maybe it’s the camera angle, let me give it a try again.

Now, for some reason, some cloud particles appears to go up and down to the planet, and the clouds seems to be in a different attitude.