Roblox Developer Logo Get Started Learn Roblox API Reference Community


Lua error in Module:API at line 338: attempt to index local 'class' (a nil value).


This example creates a path between two points and creates parts at every waypoint along that path. The code uses the Position property of the PathWaypoints to position the parts.

-- Make variables for Roblox services
local PathfindingService = game:GetService("PathfindingService")
-- Make variables for the start and end of the path
local start =, 1, 0)
local finish =, 1, -60)
-- Find the path and get the waypoints
local path = PathfindingService:FindPathAsync(start, finish)
local waypoints = path:GetWaypoints()
-- Loop through all of the waypoints in the path
for waypointIndex, waypoint in pairs(waypoints) do
	-- Create a part for each waypoint and position the part
	-- at the waypoint's position.
	local part ="Part")
	part.Size =, 1, 1)
	part.Position = waypoint.Position
	part.CanCollide = false
	part.Anchored = true
	part.Parent = game.Workspace