How to make NPC always face targetplayer

I tried using CFrame for the NPC humanoidrootpart but then the npc wouldn’t be able to use the :MoveTo function so I tried alignedorientation but I don’t know how to properly manipulate the angle to make it work.

Use CFrame.LookAt if you want it to face the player constantly

2 Likes

Could it be that you need to set “Archivable” to false?
(Above would also how I would do it)

Sorry for bumping this 5 months later. I haven’t found much documentation or any answers on how to solve this. However I found that this can be achieved through BodyGyro.

https://gyazo.com/e9b88679f4948ec13610a617bbb80187

local bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(0, 10000, 0)
bodyGyro.P = 10000
bodyGyro.Parent = hrp

task.spawn(function()
	while true do
		local target = game.Players:GetPlayers()[1] and game.Players:GetPlayers()[1].Character
		local __targetRP = target and target:FindFirstChild("HumanoidRootPart")

		if __targetRP then

			local lookDirection = (__targetRP.Position - hrp.Position).Unit
			local targetCFrame = CFrame.new(hrp.Position, hrp.Position + lookDirection)

			bodyGyro.CFrame = targetCFrame

		else

			-- If the target is not found, reset BodyGyro to prevent jitter
			bodyGyro.CFrame = CFrame.new()	-- hrp.CFrame

		end

		task.wait(.05)

	end
end)

its not perfect but it’s the best method ive found

I do this easily with AlignOrientation. You can use either the OneAttachment mode or the TwoAttachment one. Implementation will be slightly different but, I personally use OneAttachment and update the CFrame with a CFrame.lookAt towards the target to utilize pivot over another attachment. The most important thing to do is set AlignType to PrimaryAxisParallel so it only rotates about the Y-Axis. Also disable AutoRotate under your Humanoid. Hope this helps. :slight_smile: