Smoothly rotate one part to look at another

So I want the part called the player to look at the destination smoothly not instantly to lerp over and look at it, but my script for some reason is not working and I dont know why.

local RunService = game:GetService("RunService")

local Player = workspace:WaitForChild("Player")
local Destination = workspace:WaitForChild("Destination")

local function Heartbeat(DeltaTime)
	local Delta = Destination.Position - Player.Position
	local Theta = Delta.Unit * DeltaTime
	Player.CFrame = CFrame.lookAt(Player.Position, Player.Position + Theta)
	return
end

RunService.Heartbeat:Connect(Heartbeat)

Can someone tell me why?

What I recommend is using :Lerp()

local Theta = Delta.Unit * DeltaTime
local Alpha = 0.5
Player.CFrame = Player.CFrame:Lerp(CFrame.lookAt(Player.Position, Player.Position + Theta, alpha))

Also; I don’t recommend using return inside of a heartbeat function. It just gives me bad vibes.
Perhaps you’re not lerping/cframing the HumanoidRootPart?

1 Like