Abu Hurairah reported,

The Messenger of Allah ﷺ said, "Among the deeds and good works that continue to reach a believer after his death are knowledge he taught and spread, a righteous child he left behind, a copy of the Quran he passed on as inheritance, a mosque he built, a lodging he built for travelers, a river he caused to flow, or charity he gave from his wealth while in good health during his lifetime. These will reach him after his death."

Ibn Majah 242

Daif

حدثنا محمد بن يحيى حدثنا محمد بن وهب بن عطية حدثنا الوليد بن مسلم حدثنا مرزوق بن أبي الهذيل حدثني الزهري حدثني أبو عبد الله الأغر

عن أبي هريرة قال

قال رسول الله ﷺ إن مما يلحق المؤمن من عمله وحسناته بعد موته علما علمه ونشره وولدا صالحا تركه ومصحفا ورثه أو مسجدا بناه أو بيتا لابن السبيل بناه أو نهرا أجراه أو صدقة أخرجها من ماله في صحته وحياته يلحقه من بعد موته

ابن ماجه 242ضعيف
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Sunnah
Chapter
Reward for teaching people good
Numbering
Darussalam 242
Ibn Majah 242