I am having problems making my code work without certain parts repeating in a while true do or a heartbeat strong text
Here is my code:
local RS = game:GetService(“RunService”)
RS.Heartbeat:Connect(function()
local EARTHmagnitude = math.abs((script.Parent.Position - workspace.Planets.Earth.Surface.Position).Magnitude)
local MOONmagnitude = math.abs((script.Parent.Position - workspace.Planets.Moon.Surface.Position).Magnitude)
local VENUSmagnitude = math.abs((script.Parent.Position - workspace.Planets.Venus.Surface.Position).Magnitude)
if EARTHmagnitude > 367.5 then
script.Parent.BodyForce.Force = Vector3.new(0,0,0)
end
if EARTHmagnitude < 367.5 then
script.Parent.BodyForce.Force = Vector3.new(0,-792.8,0)
end
----------------------------------------------------------------------------------------------------
if MOONmagnitude > 181.5 then
script.Parent.BodyForce.Force = Vector3.new(0,0,0)
end
if MOONmagnitude < 181.5 then
script.Parent.BodyForce.Force = Vector3.new(0,-130.4,0)
end
----------------------------------------------------------------------------------------------------
if VENUSmagnitude > 367 then
script.Parent.BodyForce.Force = Vector3.new(0,0,0)
end
if VENUSmagnitude < 367 then
script.Parent.BodyForce.Force = Vector3.new(0,-709.6,0)
end
end)