How do you make things position around your character in a circle formation?

No matter how many parts there are I want them to reform around the character in a circle whenever I spawn in a new one. How can I achieve this?

EDIT: Also I’m not very familiar with math so a simple demonstration would be easier for me to understand.

So I came up with some code that will do this for me. However, I think the problem now is that the circle gets too big eventually, and doesn’t create another layer underneath. Does anyone know how to do this?

Example of how it looks currently:

Code:

``````local Parts = {}

function Reposition()
local int = .5
for i = 1,#Parts do
Parts[i].CFrame = (Origin * CFrame.Angles(0,int,0) * CFrame.new(0,0,#Parts/2))
int+=.5
end
end

while wait(.5) do

local Part = Instance.new("Part")
Part.Size = Vector3.new(.5,.5,.5)
Part.Anchored = true
Part.BrickColor = BrickColor.new("Really black")
Part.Material = Enum.Material.Neon
Part.Parent = script.Parent
Parts[#Parts+1] = Part

Reposition()

end
``````
1 Like

It’s forever moving further away from the player’s character model because you have the code inside of a never ending loop which never terminates/ends, to remedy this add some kind of limit to the loop.

``````for i = 1, 20 do
local Part = Instance.new("Part")
Part.Size = Vector3.new(.5,.5,.5)
Part.Anchored = true
Part.BrickColor = BrickColor.new("Really black")
Part.Material = Enum.Material.Neon
Part.Parent = script.Parent
Parts[#Parts+1] = Part
Reposition()
end
``````

This is just an example but it’ll run the same code 20 times every 0.05 seconds and then stop completely, play around with the “20” value until you get the desired result.

To create multiple parts at different Y axis levels and thus lower/higher rings you’ll need to call the first function multiple times and manipulate the “`Parts[i].CFrame = (Origin * CFrame.Angles(0,int,0) * CFrame.new(0,0,#Parts/2))`” line of code differently each time the function is called.

1 Like