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)