Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
H2nad 0
1 year ago
Edited by Leamir 1 year ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

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)
0
Does it give any errors on console? Does the human exists? Does 'endingPart' exist on the workspace? Leamir 3138 — 1y
0
not at all H2nad 0 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

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.

Ad

Answer this question