Pet wont stay behind the player

I want the pets to always stay behind the player, this is what it looks like right now:https://gyazo.com/2d1a7a15ff156a40cc8df190578c0371

Here’s my code (it is running every frame):

Pet.PrimaryPart.CFrame = Pet.PrimaryPart.CFrame:Lerp(CFrame.new(HumanoidRootPart.CFrame.p)
    * CFrame.Angles(0, yAngle,0)
    * CFrame.fromEulerAnglesXYZ(0, 0, cos/2)
    + Vector3.new(x,sin, z),
    0.1
)

I have tried lerping the pet’s cframe to the desired position separately before the animation lerping which solves the issue but messes up the offset values.

I would really appreciate some help.