How would I script a pet following system

Basically I’ve figured out how to make a sort of following system but I don’t know how to calculate the positioning of the pets determined by how many pets the player has equipped.

In short how would I calculate the pets positioning behind the player

Let’s say this can go up to 15.

Example can be pet simulator x(just not the animation just the positioning)

4 Likes

To position the pets relative to the player, you can use lookVector and rightVector. For example:

while wait(0.1) do
 local pet.Humanoid:MoveTo(HumanoidRootPart.Position + HumanoidRootPart.CFrame.lookVector - 10, y, HumanoidRootPart.Position + HumanoidRootPart.CFrame.rightVector + 5)
end

With this script, you can set the pet to move wherever you want around the player, whether that be behind them, to their left, or in front.

You can then just use a variable to calculate how many pets the player has equipped and then modify the positions from there.

2 Likes

I want to know how to put them in a circle which’s *100% Automatically calculates where the pets position is supposed to be

1 Like

I’m not quite sure if you can accomplish this, I haven’t coded in Roblox for a while but the best solution I can offer is to manually adjust the pets to be in a circle depending on how many pets there are.

3 Likes

I swear I’ve seen like these games with infinite equips. I also saw some free model script have it but I don’t really understand the code cuss it’s advanced. It’s also just an replicate of pet sim x’s pet following script

1 Like

Well if it’s too advanced then you could just have the pets be in a random position behind the player instead of a circle.

I would recommend trying the solution from this post.
How can I add a code that would make more than 1 pet follow me? like 2, 3, 4, or more pets follow! SOLVED! - Help and Feedback / Scripting Support - Developer Forum | Roblox