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. (Using translation from Abū Dāʾūd 2880)
عَنِ النَّبِيِّ ﷺ قَالَ إِذَا مَاتَ الْإِنْسَانُ انْقَطَعَ عَمَلُهُ إِلَّا مِنْ ثَلَاثٍ عِلْمٍ يُنْتَفَعُ بِهِ أَوْ صَدَقَةٍ تَجْرِي لَهُ أَوْ وَلَدٍ صَالِحٍ يَدْعُو لَهُ