Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with my script? I tried using the PathfindingService.

i was watching a tutorial and i tried the script and it didnt work

and yes, i did double check to make sure that i was following the tutorial right

local PathfindingService = game:GetService("PathfindingService")

local human = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")

local path = PathfindingService:CreatePath()
path:ComputeAsync(torso.Position, game.Workspace.endingPart.Position)
local waypoints = path:GetWaypoints()

for i, waypoint in pairs(waypoints) do
	human:MoveTo(waypoint.Position)
	human.MoveToFinished:Wait(2)
end

human:MoveTo(workspace.endingPart.Position)

2 comments

0

Does it give any errors on console? Does the human exists? Does 'endingPart' exist on the workspace?

0

not at all

1 answer

Adding a number as argument for a :Wait() function does nothing at all, as it doesn't take any arguments.

Nonetheless, my best guesses here would be that either the NPC is anchored, the script is a local script, or script.Parent isn't the NPC.

This discussion is preserved as it was. New answers, comments, and votes are closed.