So I already have made the pet hatching system and how to make it follow. Now I want to make it so multiple pets can follow you. But when I made my script the pets just go to 0, 50, 0. I had it working with 1 pet now adding multiple doesn't work. I'm pretty sure I'm just doing something dumb in the script but I cant figure it out. Thanks in advance!????
The pets are not models I'm just testing it out with parts first.
Script:
for rarity, weight in pairs(RarityTable) do
counter = counter + weight
if ranNumber <= counter then
petOffset.Value += 1
isPetChosen = true
local chosenPet = petsFolder:FindFirstChild(rarity)
local chosenPetCopy = chosenPet:Clone()
chosenPetCopy.Parent = game.Workspace
chosenPetCopy:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame)
local bodyPos = Instance.new("BodyPosition")
bodyPos.Parent = chosenPetCopy:FindFirstChild(rarity)
bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyPos.D = 2000
bodyPos.P = 25000
if petOffset == 1 then
while wait() do
bodyPos.Position = root.Position + Vector3.new(3.5, 2, 3.5)
end
elseif petOffset == 2 then
while wait() do
bodyPos.Position = root.Position + Vector3.new(5.5, 2, 5.5)
end
elseif petOffset == 3 then
while wait() do
bodyPos.Position = root.Position + Vector3.new(7.5, 2, 7.5)
end
end
print(rarity) -- prints rarity of pet
return --Returns to where the function started / Exits function
end
end
This script runs whenever it finds the right pet it picked.
