Pet Following System Troubles

I am trying to make a system where a pet will follow you even if it is a model. My current problem is the system I have now only works on one part or union. Any help would be great!

local Workspace = game:GetService("Workspace")

local pet = script.Parent:GetChildren() 
local localplayer = game.Players.PlayerAdded

local pet = script.Parent

function givePet (player)
 if player then
  local character = player.Character
  if character then
   local humRootPart = character.HumanoidRootPart
   local newPet = pet:Clone ()
   newPet.Parent = character
   
   local bodyPos = Instance.new("BodyPosition", newPet)
   bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
   
   local bodyGyro = Instance.new("BodyGyro", newPet)
   bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
   
   while wait() do
    bodyPos.Position = humRootPart.Position + Vector3.new(2, 2, 3)
    bodyGyro.CFrame = humRootPart.CFrame
           end
       end
    end
end

localplayer:Connect(function(player)
   player.CharacterAdded:Connect(function(char)
      givePet(player)
    end)
end)
1 Like

You can just weld the other parts to the main part or use SetPrimaryPartCFrame: https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame

Are all of the parts unanchored and welded? If not, do that and then it will work. (atleast that’s what i did for my pet following system)

edit:
You can also do this to keep it in the same position:

bodyPos.Position = (humRootPart.CFrame * CFrame.new(2, 2, 3)).p

.p Pretty much transfers CFrame to Position which is very useful.

Alright I’ll try it out. Thanks

1 Like

All my parts are unanchored and welded

I tried to use SetPrimaryPartCFrame and your method but nothing worked since it is not staying with the player.

Hm, that’s really weird. What do you get in the output?
BTW, I didn’t used math.huge for my BodyPos MaxForce, i did like 10000?

I can try that

Very interesting