The Buddha taught to go forth and be a monk, persevering and achieving the goals of the holy life.
Otherwise, if that is not possible, then try to do well as a lay person, persevering and achieving the goals of the worldly life.
Even the latter is better than growing old, achieving nothing at all.
From Dhammapada 155-156:
They, who in youth have neither led the life of Purity nor
have acquired wealth, waste away in dejection like decrepit herons on
a drying pond deplete of fish.
They, who in youth have neither led the Life of Purity nor
have acquired wealth, lie helplessly like arrows that have lost
momentum, moaning and sighing after the past.
The story in the traditional commentary:
While residing at the Migadaya wood, the Buddha uttered Verses (155)
and (156) of this book, with reference to the son of Mahadhana, a rich
man from Baranasi.
The son of Mahadhana did not study while he was young; when he came of
age he married the daughter of a rich man, who, like him, also had no
education. When the parents on both sides died, they inherited eighty
crores from each side and so were very rich. But both of them were
ignorant and knew only how to spend money and not how to keep it or to
make it grow. They just ate and drank and had a good time, squandering
their money. When they had spent all, they sold their fields and
gardens and finally their house. Thus, they became very poor and
helpless; and because they did not know how to earn a living they had
to go begging. One day, the Buddha saw the rich man's son leaning
against a wall of the monastery, taking the leftovers given him by the
samaneras; seeing him, the Buddha smiled.
The Venerable Ananda asked the Buddha why he smiled, and the Buddha
replied, "Ananda, look at this son of a very rich man; he had lived a
useless life, an aimless life of pleasure. If he had learnt to look
after his riches in the first stage of his life he would have been a
top-ranking rich man; or if he had become a bhikkhu, he could have
been an arahat, and his wife could have been an anagami. If he had
learnt to look after his riches in the second stage of his life he
would have been a second rank rich man, or if he had become a bhikkhu
he could have been an anagami, and his wife could have been a
sakadagami. If he had learnt to look after his riches in the third
stage of his life he would have been a third rank rich man, or if he
had become a bhikkhu he could have been a sakadagami, and his wife
could have been a sotapanna. However, because he had done nothing in
all the three stages of his life he had lost all his worldly riches,
he had also lost all opportunities of attaining any of the Maggas and
Phalas."