Pet following system broken?

My pet just flies somewhere and I cant find it in the players character, can anyone help?

eventFolder.EquipPet.OnServerEvent:Connect(function(player, pet)
	if player then
		local character = player.Character
		if character then
			local humRootPart = character.HumanoidRootPart
			local newPet = pet:Clone()
			newPet.Parent = character
			
			local representivePet = Instance.new("ObjectValue", newPet)
			representivePet.Value = pet
			
			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)
			
			newPet.CanCollide = false
			
			wait(0.05)
			
			while (representivePet.Value.Parent == player.EquippedPets and wait()) do
				for i, v in pairs(representivePet.Value.Parent:GetChildren()) do
					if v == representivePet.Value then
						if i == 1 then
							bodyPos.Position = humRootPart.Position + Vector3.new(0, 4, 4)
							bodyGyro.CFrame = humRootPart.CFrame
						elseif i == 2 then
							bodyPos.Position = humRootPart.Position + Vector3.new(3, 3, 4)
							bodyGyro.CFrame = humRootPart.CFrame
						elseif i == 3 then
							bodyPos.Position = humRootPart.Position + Vector3.new(-3, 3, 4)
							bodyGyro.CFrame = humRootPart.CFrame
						end
					end
				end
			end
			
			newPet:Destroy()
		end
	end
end)

can anyone help me? I really want to have this fixed today

So do you want to make pet follow you smoothly like in Ninja Legends for example?

I just want it to follow you anyway possible

Then you could tween pet’s CFrame, for example:

local pet = -- define your pet here
local HumanoidRootPart = --define root part here
local TWS = game:GetService("TweenService")

game["Run Service"].RenderStepped:Connect(function()
   local cf = HumanoidRootPart.CFrame + CFrame.new(10,10,10)
   TWS:Create(pet, TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = cf}):Play()
end)

You’re making things too complicated in my opinion.

It will work on the server side too, but it’s much smoother on the client side. Also make sure to turn off collisions on the pet so it will be even more smoother.

I tested it and it just makes my pet go straight into the sky and stopping around 50 studs above the middle of the map

It did this before and I did not know how to fix it

For more context my pet flies into the sky

That’s really weird, I just tried the following script and it worked perfectly fine:

local pet = game.ReplicatedStorage.Assets.Pets.Immortals.Dragon
local tws = game:GetService("TweenService")
local info = TweenInfo.new(.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local clone = pet:Clone()
clone.Parent = char
clone.CanCollide = false
clone.Massless = true
clone.CanTouch = false

while task.wait() do
	local cf = char.PrimaryPart.CFrame * CFrame.new(6,0,5)
	tws:Create(clone, info, {CFrame = cf}):Play()
end

I think i found something, whenever I check the CFrame of the humanoidRootPart it says something around 0, 50, 0