I heard the Messenger of Allah (ﷺ) saying during the Farewell pilgrimage: “No criminal commits a crime but he brings. (the punishment for that) upon himself. No father can bring punishment upon his son by his crime, and no son can bring punishment upon his father.”
Sunan Ibn Majah Book 21, Hadith 55