Issue with part rotation

i have a part that orbits around another part. but the rotation starts at some random position when i want it to start at the original position. like this:
image

heres whats actually happening

code:

local radius = 10
local theta = 0
local degreesPerSecond = math.rad(60)

local center = workspace.Part
local part = workspace.Part2

local function UpdateOrbit(deltaTime)
	local deltaTheta = degreesPerSecond * deltaTime
	theta = (theta + deltaTheta) % (math.pi * 2)

	local x = (math.cos(theta) * radius) + center.Position.X
	local z = (math.sin(theta) * radius) + center.Position.Z
	part.Position = Vector3.new(x, center.Position.Y, z)

end
task.wait(3)
print('running')

game:GetService("RunService").Heartbeat:Connect(UpdateOrbit)

It might be that your part isn’t starting at the script’s origin. Either move the part or change the origin of the part in the script

The reason why is because of the theta variable, this indicates what angle the orbiting part is at in relation to the circle. You can mess around with that number of that variable to find the angle you need

works properly now

local center = workspace.Part
local part = workspace.Part2

local radius = (center.Position - part.Position).Magnitude
local theta = false
local start = math.atan2(part.Position.Z - center.Position.Z, part.Position.X - center.Position.X)
local degreesPerSecond = math.rad(60)

local function UpdateOrbit(deltaTime)
	local deltaTheta = degreesPerSecond * deltaTime
	theta = theta and (theta + deltaTheta) % (math.pi * 2) or start

	local x = (math.cos(theta) * radius) + center.Position.X
	local z = (math.sin(theta) * radius) + center.Position.Z
	part.Position = Vector3.new(x, center.Position.Y, z)

end
task.wait(3)
print('running')

game:GetService("RunService").Heartbeat:Connect(UpdateOrbit)