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
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