Make NPC face waypoints

  1. What do you want to achieve? Keep it simple and clear!
    I’m attempting to make an npc navigation system. The objects the npc is navigating to will not be moving yet it is very weird.

  2. What is the issue? Include screenshots / videos if possible!
    It’s facing the wrong way, and it seems to teleport instead of walk.

Here is my code:

function Shopper:Navigate(destination)
	self.Path:ComputeAsync(self.Char.PrimaryPart.Position, destination)
	local waypoints = self.Path:GetWaypoints()
	for i, waypoint: PathWaypoint in next, waypoints do
		if i < #waypoints then
			self:LookAt((waypoints[i + 1].Position +, 3, 0)) , 1, true)

and Shopper:LookAt

function Shopper:LookAt(destination, timer, yield)
	local d ="Part", workspace)
	d.Size =, 0.25, 0.25)
	d.Anchored = true
	d.CFrame = getCFrame(self.Char.PrimaryPart.Position, destination)
	local h ="Highlight", d)
	local t = TS:Create(self.Char.PrimaryPart, or 0.5), {
		CFrame = getCFrame(self.Char.PrimaryPart.Position, destination)
	if yield then

I saw this post related to the new, CFrame.fromMatrix, so I attempted to use that instead of CFrame.lookAt, but CFrame.lookAt doesn’t work properly as well.
the function getCFrame is just the code from that post.

local function getCFrame(position, lookAt)
    local lookVector = (position - lookAt).Unit 
    local modelUpVector =, 1, 0)
    local rightVector = lookVector:Cross(modelUpVector)
    local upVector = rightVector:Cross(lookVector)
    return CFrame.fromMatrix(position, rightVector, upVector)

I’ve tried inversing the vector3 in
self:LookAt((waypoints[i + 1].Position +, 3, 0)) , 1, true) by doing
-self:LookAt((waypoints[i + 1].Position +, 3, 0)) , 1, true)
Unfortunately that doesn’t work either. How am I supposed to properly orient the NPC to face the waypoint it’s walking to?

Another thing, when I comment out the code to make the npc look at the next waypoint, the choppy teleporting stops and it walks properly.
In addition, I’ve already set the network owner of the npc to nil (aka the server)

1 Like