The script creates one node each time when it should be creating more then one why and how do I fix it?
Even though the script fails to visualize the path the Character still moves.
Pathfinding = game:GetService("PathfindingService")
Character = game.Workspace.Character.Humanoid
Start = Character.Torso.Position
End = Vector3.new(10,10,10)
---------------------------
function FindPointModel()
local FoundPointModel = game.Workspace:FindFirstChild("PointModel")
if not FoundPointModel then
local Model = Instance.new("Model",game.Workspace)
Model.Name = "PointModel"
else return FoundPointModel--If found then return the Model
end
end
---------------------------
function VisualizePath(Path)
local Points = Path:GetPointCoordinates()
for _,Point in pairs(Points) do
print("Given Points are : ",Point)
local Part = Instance.new("Part",FindPointModel())--Creates Nodes
Part.Position = Point
Part.Name = "Nodes"
Part.Anchored = true
Part.Size = Vector3.new(1,1,1)
Part.CanCollide = false
return Points --Returns Vairble Points:Path:GetPointCoordinates()
end
end
---------------------------
Path = Pathfinding:ComputeSmoothPathAsync(Start,End,512)
Points = VisualizePath(Path)
for i,v in pairs (Points) do
Character:MoveTo(v)
end
