I have a script that makes a ball orbit the player when it’s touched. As more balls orbit the player, I want it to evenly space around the player. How would I do this?
local touched = false
script.Parent.Touched:Connect(function(char)
if touched == false then
touched = true
wait(0.01)
local center = char.Parent.HumanoidRootPart
local moon = script.Parent
script.Parent.Parent = workspace[char.Parent.Name]
local ORBIT_TIME = 2
local RADIUS = 5
local ECLIPSE = 1
local ROTATION = CFrame.Angles(0,0,0)
local sin, cos = math.sin, math.cos
local ROTSPEED = math.pi*2/ORBIT_TIME
ECLIPSE = ECLIPSE * RADIUS
local runservice = game:GetService('RunService')
local rot = 0
game:GetService('RunService').Stepped:connect(function(t, dt)
rot = rot + dt * ROTSPEED
moon.CFrame = ROTATION * CFrame.new(sin(rot)*ECLIPSE, 0, cos(rot)*RADIUS) + center.Position
end)
end
end)