Help with npc looking at player while moving

How would I make it so the front of the npc always faces the player while it moves?(Not using cframe because it effects the npc’s movement)
robloxapp-20230803-2255434.wmv (1.7 MB)
Any help is appreciated


You WOULD use CFrame for this but add a CFrame.Angles() to the end of the positional set.

IE. NPC.CFrame = Magic, Position of Player) or
NPC.CFrame = Magic) + CFrame.Angles(RadX,RadY,RadZ)

This is my current script:


local NPC = game.Workspace:WaitForChild("Tank")
local HuamnoidRootPart = NPC.PrimaryPart
local Target = Character
Target = Target:WaitForChild("HumanoidRootPart")

while true do
	NPC:SetPrimaryPartCFrame(CFrame.lookAt(HuamnoidRootPart.Position, Target.Position *, 0, 1) + HuamnoidRootPart.Position *, 1, 0)))

But idk where to put the CFrame.Angles() part

1 Like

I dont think your CFrame.lookAt is doing what you want it to do. The first parameter is the position the part should be and the second is where it should be facing. But in your usage, you have position the same, the target lookAt is some crazy vector math.

Maybe the sum or the difference of the current NPC’s position with the Target’s position as the first parameter, then the position of the Target as the second parameter. since you only need to move the NPC towards the direction of the Target by very small amounts

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.