Me again lol. So i'm trying to make this game where an npc follows the player but i'm having trouble getting the NPC to find the player and go towards it. No matter what i do the error on title always appears and i can't seem to find the problem. I'd really appreciate some help. Here's the code. Thanks in advance. By the way, it redirects to line 5.
local NPC = game.Workspace:FindFirstChild("Builder Dude")
local humanoid = NPC:WaitForChild("Humanoid")
while true do
local nearestPlayer = game.Players:FindNearestPlayer(NPC.HumanoidRootPart.Position)
if nearestPlayer then
humanoid:MoveTo(nearestPlayer.Character.HumanoidRootPart.CFrame)
end
wait(1)
end
