Getting a error while creating waypoints

Hello,

So i’m making a npc that needs to go to a certain position but when I try to get the waypoints it gives thsi error: “GetWayPoints is not a valid member of Path “Instance”” If you can help me please reply!

Here’s the script:


local pfs = game:GetService("PathfindingService")

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

local path = pfs:CreatePath()
path:ComputeAsync(torso.Position, game.Workspace.AIParts.HouseSet.Destination.PrimaryPart.Position)

local waypoints
waypoints = path:GetWayPoints()

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

human:MoveTo(game.Workspace.AIParts.HouseSet.EndPart.Position)
4 Likes

Having looked it up on the dev forum, I believe the command you are looking for is :GetWaypoints(), with no capital letter for the P in “Points”.

https://developer.roblox.com/en-us/api-reference/function/Path/GetWaypoints