# How do I make more than one pet follow a player without overlapping eachother?

Hello! I am working on a pet system for my game right now and one thing I can’t figure out how to have more than one pets following a player without those pets overlapping eachother, I want these pets circled around a player.

I have tried to look up solutions here but I cannot find any.

Could anyone help? It would be so much appreciated

here is a demo project that might help
Positioning parts like a star.rbxl (34.7 KB)

and this is what it looks like

and this is the script inside the demo project

``````local runService = game:GetService("RunService")

local character = script.Parent
local rootPart = character.HumanoidRootPart
local distance = 10
local amount = 5
local parts = {}

for i = 1, amount do
parts[i] = Instance.new("Part")
parts[i].Anchored = true
parts[i].Size = Vector3.new(2, 2, 2)
parts[i].Parent = workspace
end

runService.Heartbeat:Connect(function(deltaTime)
for i = 1, amount do
local angle = i / amount * math.pi * 2
local offset = Vector3.new(math.sin(angle), 0, math.cos(angle)) * distance
parts[i].Position = rootPart.Position + offset
end
end)
``````

and this video might help you understand the `angle = i / amount * math.pi * 2` part

i will hopefully have a video in the future talking about sin and cos

2 Likes

Thanks for this, I can’t wrap myself around this confusing code so what I decided to do is add a vector3 value on X and Z for each number of pets, so like Vector3.new(5 + 2 * pets, 0, 5 + 2 * pets)