My npc not doing its job

code i tried to make my npc go to its destination but it is not doing it. am i doing something wrong?

if i am doing something wrong please tell me.

try checking if the NPC’s root is anchored because that will stop it from moving.

what is that? i dont know what root is.

find the NPC model, select all of the parts, then click the anchored button in the properties window until there is no checkmark.

local pfinding = game:GetService("PathfindingService")
local human = script.Parent:FindFirstChild("Humanoid")
local torso = script.Parent:FindFirstChild("Torso")

local path = pfinding:CreatePath()
parth:ComputeAsync(torso.Position, game.Workspace.endingPart.Position)

local waypoints = path:GetWaypoints() -- First mistake here. It has to be :GetWaypoints with a lowercase p...

for i, waypoint in pairs(waypoints) do
    local part = Instance.new("Part")
    part.Shape = "Ball"
    part.Material = "Neon"
    part.Size = Vector3.new(0.6, 0.6, 0.6)
    part.Position = waypoint.Position + Vector3.new(0,2,0)
    part.Anchored = true
    part.CanCollide = false
    part.Parent = game.Workspace

    if waypoint.Action == Enum.PathWaypointAction.Jump then
        human:ChangeState(Enum.HumanoidStateType.Jumping)
    end
    human:MoveTo(waypoint.Position)
    human.MoveToFinished:Wait(2)
end


human:MoveTo(game.Workspace.endingPart.Position)
1 Like

There are to variables named “waypoints”. Try changing their names? One of them is getting the created Path.

thanks it worked. thank you for the help.

We all gotta love those small typos