How can i make my pets don't overlap each other in a organized way?

I’m making a game that consists on a tower defense, but i was asking, how could i make like, when i have like 2 pets the 1 one goes on the left and the 2 one goes on the right and the 3 goes on the middle and etc. How can i make that? If i don’t do that, the pet’s will overlap and will cause a bad thing.

Here’s my code:

local RS = game:GetService("ReplicatedStorage")
local SummonEvent = RS:WaitForChild("SummonEvent")
local SummonSound = script:WaitForChild("SummonSound")

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character

local PetsFolder = RS.Pets:GetChildren()

local TS = game:GetService("TweenService")
local CC = workspace.CurrentCamera
local RunService = game:GetService("RunService")

local PetFollowConnection

SummonEvent.OnClientEvent:Connect(function(CamPart, Prompt)
	CC.CameraType = Enum.CameraType.Scriptable
	Prompt.Enabled = false
	local CamTS = TS:Create(
		CC,
		TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
		{CFrame = CamPart.CFrame}
	)
	CamTS:Play()
	SummonSound:Play()
	task.wait(3)
	Prompt.Enabled = true
	
	CC.CameraType = Enum.CameraType.Custom
	local RandomPet = PetsFolder[math.random(1, #PetsFolder)]:Clone()
	RandomPet.Parent = workspace
	PetFollowConnection = RunService.RenderStepped:Connect(function()
		RandomPet.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(-2, 0, 3)
	end)
end)
1 Like

you could put them in an array, create target destinations relative to each other according to the length, and tween them to it?

2 Likes

what, i didn’t understand, can you provide me a code example?

1 Like