This script is supposed to make a part orbit around the player. It test mode, it works perfectly and orbits around the player in a complete circle, smooth and everything. In the normal game, it just glitches around them then decides, "oh hey I'll go through the ground now". (Gotta love roblox's perfect and reliable test mode)
Here is the script, any idea what's causing this?
local Satellite = script.Parent local Body = script.Parent.Parent.HumanoidRootPart orbitPeriod = 2 orbitRadius = 10 orbitVerticalDisplacement = 0 for t = 0, math.huge do Satellite.Position = CFrame.new(Body.Position)*CFrame.Angles(0, t/orbitPeriod * math.pi/30, 0)*Vector3.new(orbitRadius, orbitVerticalDisplacement, 0) game['Run Service'].Heartbeat:wait() end
Thanks for reading
I'm pretty sure something such as this works:
local t = 0; game:GetService("RunService").RenderStepped:Connect(function() satellite.CFrame = CFrame.new(body.Position) * CFrame.Angles(0, math.rad(t), 0) * CFrame.new(0, 0, orbitRadius) t = t + 1; end)
Of course, you'll have to change all of the desired variables and values, but something similar to this should work as a framework for having the "satellite" object orbit an object called "body."
Hope this helps