I try to make pathfiding system, it can set goals in order. (Sorry for my incomplete code)
However, the service don’t work well like attachment movie.
So, are there any ideas to solve this problem, and if you have any opinions about this issue, pls reply this forum. I appreciate your valuable replying!
◆Problem
NPC can’t move smoothly and often stop and face the wall (in addition, repeat jump)
◆Script
local Start = game.ReplicatedStorage["Seek"].chaseStart
local Humanoid = script.Parent.Humanoid
local Root = script.Parent:FindFirstChild("HumanoidRootPart")
local goal1 = game.Workspace["maze"]["Point"].Point1.Position
local goal2 = game.Workspace["maze"]["Point"].Point2.Position
local goal3 = game.Workspace["maze"]["Point"].Point3.Position
local goal4 = game.Workspace["maze"]["Point"].Point4.Position
local goal5 = game.Workspace["maze"]["Point"].Point5.Position
local goal6 = game.Workspace["maze"]["Point"].Point6.Position
local goal7 = game.Workspace["maze"]["Point"].Point7.Position
local goals = {
goal1,
goal2,
goal3,
goal4,
goal5,
goal6,
goal7
}
local path = PathfindingService:CreatePath()
local reachedConnection
Start.OnServerEvent:Connect(function(player)
for i = 1, #goals do
local success, errorMessage = pcall(function()
path:ComputeAsync(Root.Position, goals[i])
end)
if success and path.Status == Enum.PathStatus.Success then
print("success")
local waypoints = path:GetWaypoints()
for v, waypoint in ipairs(waypoints) do
Humanoid:MoveTo(waypoint.Position)
if waypoint.Action == Enum.PathWaypointAction.Jump then
Humanoid.Jump = true
end
Humanoid.MoveToFinished:Wait()
end
end
if errorMessage then
print ("error")
end
wait()
end
end)```