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

Can anyone help me with my pathfinding script? it is having some issues which dont make sense

Asked by
kom297 -4
6 years ago

Whenever i try to run my script it outputs this "13:52:44.021 - Workspace.NPC.Script:9: function arguments expected near 'for'" Here is my script:

local torso = script.Parent.Torso
local base = workspace.Base.Position
local humanoid = script.Parent.Humanoid


local path = game:GetService("PathfindingService"):FindPathAsync(torso,base)
local points = path:GetWaypoints

for i,v in pairs(points) do
    local p = Instance.new("Part",workspace)
    p.Anchored = true
    p.CanCollide = false
    p.CFrame = CFrame.new(v.Position)
    p.Size = Vector3.new(1,1,1,)
end

if  path.Status == Enum.PathStatus.Success then
    for i,v in pairs(points) do
        human:MoveTo(v.Position)
        human:.MoveToFinished:wait()
        if  v.Action == Enum.PathWaypointAction.Jump then
            humanoid.Jump = true
        end
    end
end

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

On line seven, you forgot to finish the :GetWaypoints() function/method. Just change
local points = path:GetWaypoints

to

local points = path:GetWaypoints()

EDIT: Also on line 20 you seem to have made a typo.

human:.MoveToFinished:wait()

should be

human.MoveToFinished:wait()

0
Thanks but now its a new problem xd now it says "14:20:41.344 - Workspace.NPC.Script:14: unexpected symbol near ')'" kom297 -4 — 6y
0
p.Size = Vector3.new(1,1,1,) Should be p.Size = Vector3.new(1,1,1) Try it now :) TayBoss76 22 — 6y
0
Thanks this script hates me xddd now it says "14:23:04.722 - Workspace.NPC.Script:20: function arguments expected near ':'" im so sorry lol thanks so much for your help kom297 -4 — 6y
0
Yes, look at the original answer, change human:.MoveToFinished:wait() to human.MoveToFinished:wait() That should do it. TayBoss76 22 — 6y
View all comments (4 more)
0
Thanks this script must hate me now it says " 14:25:37.352 - Unable to cast Instance to Vector3" kom297 -4 — 6y
0
Try adding .Position at the end of line 1. TayBoss76 22 — 6y
0
Thanks so much now it works :D kom297 -4 — 6y
0
Np. TayBoss76 22 — 6y
Ad

Answer this question