However, it starts to glitch out for no reason after a set amount of time. I’m thinking it has something to do with the code
-- Variables
local RunService = game:GetService("RunService")
local NoteBookPrimaryPart = game.Workspace:WaitForChild("NotebookJ"):WaitForChild("PrimaryPart")
local R6xer = game.Workspace:WaitForChild("R6"):WaitForChild("center")
local LockerPrimaryPart = game.Workspace:WaitForChild("Locker"):WaitForChild("Primary Part")
-- Variables for Orbiting
local Speed = 0.02
local Speed2 = 0.01
local i = 0
local ind = 4
local distance = 8.5
local distance2 = 9
local Angle = math.rad(0)
RunService.Heartbeat:Connect(function()
i = i + 1
ind = ind + 1
NoteBookPrimaryPart.CFrame =R6xer.CFrame * CFrame.fromEulerAnglesXYZ(-i*Speed, Angle, i*Speed) * CFrame.new(0,0,distance)
LockerPrimaryPart.CFrame = R6xer.CFrame * CFrame.fromEulerAnglesXYZ(ind*Speed2, math.rad(55),ind*Speed2) * CFrame.new(0,0,distance2)
print(i)
end)
i know you want a fix to your system you have right now, but is there no way that you can do this with tweens? you would have to rely on the math matching up perfectly
Hello whats the issue here?
Simply use this formula
r: is the separation distance between the two bodies
theta: is the angle that r makes with the axis of periapsis