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

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

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

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()

8 comments

0

Thanks but now its a new problem xd now it says "14:20:41.344 - Workspace.NPC.Script:14: unexpected symbol near ')'"

0

p.Size = Vector3.new(1,1,1,) Should be p.Size = Vector3.new(1,1,1) Try it now :)

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

0

Yes, look at the original answer, change human:.MoveToFinished:wait() to human.MoveToFinished:wait() That should do it.

0

Thanks this script must hate me now it says " 14:25:37.352 - Unable to cast Instance to Vector3"

0

Try adding .Position at the end of line 1.

0

Thanks so much now it works :D

0

Np.

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