most of my code isnt working - pathfinding, tables, etc
EXAMPLE
local module = {}
-- //Services
local PathfindingService = game:GetService("PathfindingService")
-- //Folders
local NPCs = workspace:WaitForChild("NPCs")
local PathfindingFolder = workspace:WaitForChild("Pathfinding")
local StationFolder = PathfindingFolder:FindFirstChild("Stations")
local WaypointFolder = PathfindingFolder:FindFirstChild("Waypoints")
local BlockedParts = PathfindingFolder:FindFirstChild("BlockedParts")
local Values = script.Parent:FindFirstChild("Values")
-- //PathfindingService
local Path = PathfindingService:CreatePath({
AgentRadius = 2,
AgentHeight = 2,
AgentCanJump = true,
AgentCanClimb = true,
WaypointSpacing = 5,
Costs = {
Block = 1,
}
})
-- //Tables
local WaypointIndex = {}
-- //StringValues
local Ticket = Values:FindFirstChild("Ticket")
local Station = Values:FindFirstChild("Station")
local Train = Values:FindFirstChild("Train")
function module:Pathfinding(player, character, Rig)
-- //Humanoid
local RigHumanoid = Rig:FindFirstChild("Humanoid")
-- //for loop WaypointFolder
for _, Part in ipairs(WaypointFolder:GetChildren()) do
WaypointIndex[Part.Name] = Part.CFrame
print(WaypointIndex)
local success, errorMessage = pcall(function()
Path:ComputeAsync(Rig.PrimaryPart.Position, WaypointIndex[Part.Name])
end)
print(success, Path.Status)
-- //check
if success and Path.Status == Enum.PathStatus.Success then
RigHumanoid:MoveTo(WaypointIndex[Part.Name])
else
warn("No Path found for:", Rig.Name)
end
-- //for loop blocked
end
-- //
end
return module
OUTPUT
20:42:36.012 ▼ {
["Part"] = -2.44783769e-06, 19, 46, 0, 0, -1, 0, 1, 0, 1, 0, 0
} - Server - WaypointModule:47
20:42:36.013 false Enum.PathStatus.NoPath - Server - WaypointModule:55
20:42:36.013 No Path found for: Rig - Server - WaypointModule:62
PATH