# How do I make x parts form into a circle around the player?

Hi, I’m trying to make x parts form into a circle around the player however I’m experiencing some issues since I’m using Attachments to keep following the player.I know how to do this with CFrame.new however since Attachment is only allowing Vector3.new() I’m stuck

``````equipPetEvent.OnServerEvent:Connect(function(plr,pet)

local amountPetsEquipped = plr:FindFirstChild("AmountPetsEquipped")
local char = plr.Character
local humanoidRootPart = char.HumanoidRootPart
local clonedPet = petsFolder[pet]:Clone()
clonedPet.Name = pet
clonedPet:SetPrimaryPartCFrame(humanoidRootPart.CFrame)

local attachmentChar = Instance.new("Attachment",humanoidRootPart)
attachmentChar.Position = Vector3.new(amountPetsEquipped.Value+1,1,4) --Problem lays around here
attachmentChar.Visible = false
``````

Hi!

Well first of all, you can get a Vector3 from a CFrame by taking CFrame.p (the position).

Position won’t include the rotation. But if that’s fine, then you can also just remember that you can find points on a circle using sine and cosine.

You want to have x parts on a circle, and a full circle is 2pi radians (also known as 360 degrees). So to evenly space them, each item must be placed 2pi/x radians further than the previous.

Then to get a position from the angle, you can do:

``````local angle = myItemNumber * 2 * math.pi / totalAmountOfItems
local positionOnCircle = Vector3.new(math.sin(angle), 0, math.cos(angle))
``````

Then add the position where you want to center the circle, and by using this to set the position of each item, they should go in a nice circle of (distance from center) radius 1. Just multiply positionOnCircle by whatever radius you want, to change the size of the circle.

Note that if you have a function to add a single item, you will have to reposition the previous items (since their angle changed to make room for the extra item). And the same goes for if you were to remove an item, naturally.

Good luck!

9 Likes