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

Pathfinding doesn't seem to work why?

Asked by
DevingDev 346 Moderation Voter
6 years ago
Edited 6 years ago

So, I'm trying to learn pathfinding but this does not work why? I just want it to create bricks between start point and the end point to soon make the npc follow them. And i don't have any errors the print("Creating...") just doesn't want to print.

Server Script:

local ps = game:GetService("PathfindingService")

local pointmodel = workspace.Points

function createPath(path)
    pointmodel:ClearAllChildren()   

    local points = path:GetPointCoordinates()
    print("Starting to create..")
    for _, point in ipairs(points) do
        print("Creating...")
        local part = Instance.new("Part")
        part.FormFactor = Enum.FormFactor.Custom
        part.Size = Vector3.new(1,1,1)
        part.Position = point
        part.Anchored = true
        part.CanCollide = false
        part.Parent = pointmodel
    end
end

local Start = workspace.Start.Position
local End = workspace.End.Position

local p = ps:ComputeSmoothPathAsync(Start, End, 500)

createPath(p)

if p.Status == Enum.PathStatus.FailStartNotEmpty or p.Status == Enum.PathStatus.FailFinishNotEmpty then
    print("Compute failed")
    return {}
end

return p:GetPointCoordinates()
1
You are using the old path finding functions check out the new path finding on the wiki page. User#5423 17 — 6y
0
oh DevingDev 346 — 6y
0
But it made it harder for me to make an npc follow the path DevingDev 346 — 6y
0
No it uses the same system but a different function returns the data User#5423 17 — 6y
View all comments (3 more)
0
ok okay but can you make so walls is invis and not cancollide so i can't walk trough them but the NPC still finds the path instead of going trough the wall? DevingDev 346 — 6y
0
is it possible for me to make* DevingDev 346 — 6y
0
i can not i can't DevingDev 346 — 6y

Answer this question