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

8 comments
Position is a Vector3 value, not a CFrame value.
Changing it from CFrame to Vector3 gives me this error: attempt to multiply a Vector3 with an incompatible value type or nil, and it doesn't work at all.
You can't multiply a Vector3, you can only add.
I'm pretty sure that you can multiply a Vector3.
It is possible to multiply a Vector3 to an int or float value, but not with a CFrame, such as what you are trying to do.
So, any ideas on how I should fix this? Changing it all to CFrame still glitches it out pretty bad
Is the script a local script?
When you test in studio, everything is local. In a normal game, server scripts can lag or delay.