Pathfinding not working correctly


My pathfinding AI sometimes just doesnt move while the others do. I have been trying to fix this but i could just not manage to do it

Function to create the path

 local function followPath(destinationObject)
	local path = pfs:CreatePath()
	local succ, err = pcall(function()
		path:ComputeAsync(script.Parent.Torso.Position, destinationObject)
	end)
	if err then
		print(err)
	end
	if succ then
		for _,w in pairs(path:GetWaypoints()) do
			if w.Action == Enum.PathWaypointAction.Jump then
				script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
			end
			script.Parent.Humanoid:MoveTo(w.Position)
			if path.Status == Enum.PathStatus.Success then
				script.Parent.Humanoid.MoveToFinished:Wait()
			end
		end
	else
		followPath(destinationObject)
	end
end

getting a position between 2 points to move to.

local function CalculatePosition(i)
	if i == 1 then
		local x = math.random(-139.544, -97.881)
		local z = math.random(573.534, 618.227)
		local pos = Vector3.new(x,40.439,z)
		return pos
	elseif i == 2 then
		local x = -79.256
		local z = math.random(405.074, 432.874)
		local pos = Vector3.new(x,40.439,z)
		return pos
	end
end

randomly choose the path

followPath(CalculatePosition(math.random(1,2)))