How to do NPC looks at player

How would i implement so my Slender NPC looks at the player when teleporting?

this is the current code :

task.wait(0.15)
local Slender
local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local eventeffect = replicated:WaitForChild("Teleport")
local event2 = replicated:WaitForChild("SlenderJumpscare")

local debris = game:GetService("Debris")
local HowAggressive, HowAggressive2 = 5,7 -- Default is 15 and 20
local CooldownTime, CooldownTime2 = 5,7 -- Default is 15 and 20

local character
local hrp

local vectors = {"rightVector", "lookVector"}
local scalars = {-10, 16}



if workspace:FindFirstChild("Slenderman") then
	while task.wait(.1) do
		Slender = workspace:WaitForChild("Slenderman")
		hrp = Slender:WaitForChild("HumanoidRootPart")
		task.wait(CooldownTime, CooldownTime2)
		
		local stopattack = HowAggressive
		local stopattack2 = HowAggressive2
		
		print("behind you")

		local children = players:GetChildren()
		
		local chosen = children[#children]
		local chosen2 = children[math.random(1,#children)]

		
		local choosench = chosen.Character
		local choosench2 = chosen2.Character
		local humanoid = choosench2:WaitForChild("Humanoid")
		if humanoid.Health > 0 then
			
		
		
		task.wait()
			Slender:PivotTo(choosench2:GetPivot() * CFrame.Angles(0, math.rad(math.random(0, 360)), 0) + hrp.CFrame[vectors[math.random(#vectors)]] * scalars[math.random(#scalars)])
			eventeffect:FireClient(chosen2)
			task.wait()
			
					print(choosench2.Name.." Is Getting Attacked")
		end

		task.wait(math.random(stopattack,stopattack2))

		print("Attack Stopped for "..choosench2.Name)
		
		task.wait(0.15)
		
	end
end


Just make the cframe of npc look towards the player or add a bodygyro to it

Are you trying to make his entire body turn to face the player, or just his head?

His entire body

This text will be blurred

enemyHrp.CFrame = CFrame.lookAt(enemyHrp.Position, characterHrp.Position)

--enemyHrp is the enemy's humanoid root part
--characterHrp is the character's humanoid root part

Here’s a general gist of what you need to do.

1 Like