The code I posted was used to create the nodes for the pets to follow so you would need to use your AlignPostion and AlignOrientation code snippets and assign each pet to one of those nodes.
local alignPos = Instance.new("AlignPosition")
alignPos.MaxForce = 25000
alignPos.Attachment0 = attachPet
alignPos.Attachment1 = attachChar --Instead of attaching to the character have it attach to one of the nodes
alignPos.Responsiveness = 10
alignPos.Parent = clone
local alignOr = Instance.new("AlignOrientation", clone)
alignOr.MaxTorque = 25000
alignOr.Attachment0 = attachPet
alignOr.Attachment1 = attachChar --Instead of attaching to the character have it attach to one of the nodes
alignOr.Responsiveness = 10
The function I provided was just used to position the nodes that the pets should use to follow the player. Basically you should call the function whenever a player changes the number of pets they have equipped to fit for the required amount of pets.
I was explaining that here. Make the pets AlignPosition and AlignOrientation be set to follow one of the nodes (aka the parts that my function was creating).
What are the current properties of your AlignPosition? Since if they are to weak it’s going to cause issues. I would also recommend making the pets massless.
The OverlapMultiplier was a parameter to change the radius of the circle in which the nodes were generated. It was there to give some wiggle room depending on how big your pets are.
I think the issue is that you keep trying to do local node = setPetNodes(amountEquipped, 1) which is flawed since my function doesn’t return any value as it stands right now. If you would want this to work you would need to modify my function to add add each node in the for loop to a table and return that at the end of the function.
It would be a messier approach but all of the Node Parts are parented in the Player’s Character. It would not be an ideal approach. If you want like I can modify the function to return the table of nodes.
Now when using this function it’s going to return a table so when assigning pets to each node you will need to iterate over the table to assign each to pet to one of the nodes.
local function setPetNodes(petCount,overlapMultipler)
local rotationOffset = 360/petCount --Determine how much degrees must be seperated between pets
local = nodeTable = {}
for petNode = 1,petCount do
local currentNode = Instance.new("Part")
currentNode.Name = "Pet Node "..petNode
currentNode.Size = Vector3.new(1,1,1)
currentNode.CFrame = CFrame.Angles(0,math.rad(rotationOffset*petNode),0) * CFrame.new(-game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame.LookVector*math.max(petCount*overlapMultipler,4)) * game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
local weld = Instance.new("WeldConstraint")
weld.Parent = currentNode
weld.Part0 = game.Players.LocalPlayer.Character.HumanoidRootPart
weld.Part1 = currentNode
currentNode.Parent = game.Players.LocalPlayer.Character
table.insert(nodeTable,currentNode)
end
return nodeTable
end