This function returns an array of all the
DataType/PathWaypoint|PathWaypoints in a
Path, as computed by
Each waypoint in the array specifies a
DataType/Vector3 position and
Enum/PathWaypointAction|action to take when this PathWaypoint is reached. The array is arranged in the order of waypoints from the path start to path end.
If a path could not be computed, this function will return an empty array.
An array of
Get Path Waypoints
The example below demonstrates how to create a
Path and it’s
DataType/PathWaypoint|PathWaypoints using the
It tries to
PathService/ComputeAsyc a path between two
DataType/Vector3 positions, from pathStart to pathEnd. If a path is successfully created, indicated by it’s
Enum/PathStatus, the code block gets an array of its waypoints using
PathService/GetWaypoints. Then, it loops through the array and prints each waypoint’s position.
local PathfindingService = game:GetService("PathfindingService") -- Create path object local path = PathfindingService:CreatePath() local pathStart = Vector3.new(0, 1, 0) local pathEnd = Vector3.new(100, 1, 25) -- Compute and check the path path:ComputeAsync(pathStart, pathEnd) if path.Status == Enum.PathStatus.Success then -- Get path waypoints local waypoints = path:GetWaypoints() -- Loop through waypoints for _, waypoint in pairs(waypoints) do -- Output position of waypoint print(waypoint.Position) end end