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

[SOLVED] Why am I getting this error?

Asked by 3 years ago
Edited by Leamir 3 years ago

This question has been solved by the original poster.

I am making a pathfinding ai dummy for a game and I get this error what should I do?

local function createPath(position)
    local path = pathFindingService:CreatePath()

    path:ComputeAsync(root.Position, position)
end

local function moveTo(position)
    local path = createPath(position)

    for i, waypoint in pairs(path:GetWaypoints()) do
        if waypoint.Action == Enum.PathWaypointAction.Jump then
            humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
        end

        if path.Status == Enum.PathStatus.NoPath then
            moveTo(position)
        end

        humanoid:MoveTo(waypoint.Position)
        humanoid.MoveToFinsished:Wait()
    end
end

I get the error: Workspace.AIDummy.AI:42: attempt to index nil with 'GetWaypoints'

I forgot to return the path lol

Answer this question