Object Rotation and Follow (pet system)

This is my code for a simple pet follow

local runService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local blackToothless = game.ReplicatedStorage.DragonCompanion
local blackToothlessClone = blackToothless:Clone()
blackToothlessClone.Parent = game.Workspace

runService.RenderStepped:Connect(function()
	if (blackToothlessClone.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).Magnitude <= 15 then
		local newPosition = player.Character.HumanoidRootPart.CFrame.Position + Vector3.new(5, 3, 5)
		blackToothlessClone.HumanoidRootPart.CFrame = blackToothlessClone.HumanoidRootPart.CFrame:Lerp(CFrame.new(newPosition), 0.05)
	end
end)

However I don’t know how to make it rotate with the player, I want it to face the same direction player is facing

I believe you could do

blackToothlessClone.HumanoidRootPart.Rotation = player.Characther.HumanoidRootPart.Rotation

Place inside RenderStepped Function

I tried that but I think it gave me an error with “Vector3 expected, got number”

local petPart = blackToothlessClone.HumanoidRootPar
local petCFrame = petPart.CFrame
local charPart = player.Character.HumanoidRootPart
local charCFrame = charPart.CFrame
local x, y, z = charCFrame:ToOrientation()
petPart.CFrame = CFrame.new(petCFrame.Position) * CFrame.fromOrientation(x, y, z)

Pretty sure theres a better way to go about this but this is all I could think of at the moment

what red4erik said may work. Though I’m not sure why the Rotation didn’t come back as a Vector3

Just do instead of position + vector3

CFrame * CFrame(set the offsets in here and they will include the orientation of the player!)