Sahih Muslim 1505
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
لاَ يَمْنَعُكِ ذَلِكِ فَإِنَّمَا الْوَلاَءُ لِمَنْ أَعْتَقَ "
Abu Huraira (Allah be pleased with him) reported:
A'isha (Allah be pleated with her) thought of buying a slave-girl and emancipating her, but her owners refused to (sell her but on the condition) that the right of inheritance would vest in them. She made a mention of that to Allah's Messenger (ﷺ). whereupon he said: Let this (condition) not stand in your way for the right of inheritance vests with one who emancipates.
Full reference and source
Sahih Muslim 1505 In-book : Book 20, Hadith 18 USC-MSA web (English) : Book 9, Hadith 3595 (deprecated)
View source on Sunnah.com (opens in a new tab)