I’m using pathfinding and I need to know how to stop it after a certain amount of time
How would I do this?
local function search()
local destination = game.Players:GetChildren()[1].Character:FindFirstChild('HumanoidRootPart').Position
-- create path object
local path = pathfindingService:CreatePath()
-- compute a path
path:ComputeAsync(body.Position, destination)
-- get the waypoints table
local waypoints = path:GetWaypoints()
for k, waypoint in pairs(waypoints) do
humanoid:MoveTo(waypoint.Position)
-- change humanoid state to jump if necessary
if waypoint.Action == Enum.PathWaypointAction.Jump then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
humanoid.MoveToFinished:Wait()
end
end
Thats my code