The Messenger of Allah ﷺ as saying: When a man dies, his action discontinues from him except three things, namely, perpetual sadaqah (charity), or the knowledge by which benefit is acquired, or a pious child who prays for him.
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا مَاتَ الإِنْسَانُ انْقَطَعَ عَنْهُ عَمَلُهُ إِلاَّ مِنْ ثَلاَثَةِ أَشْيَاءَ مِنْ صَدَقَةٍ جَارِيَةٍ أَوْ عِلْمٍ يُنْتَفَعُ بِهِ أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ