The condition that makes the words work
ʿUtban reports it as said to him personally.
لَنْ يُوَافِيَ عَبْدٌ يَوْمَ الْقِيَامَةِ يَقُولُ لاَ إِلَهَ إِلاَّ اللَّهُ. يَبْتَغِي بِهِ وَجْهَ اللَّهِ، إِلاَّ حَرَّمَ اللَّهُ عَلَيْهِ النَّارَ
Lan yuwāfiya ʿabdun yawma-l-qiyāmati yaqūlu lā ilāha illā-Llāh, yabtaghī bihi wajha-Llāh, illā ḥarrama-Llāhu ʿalayhi-n-nār
“No servant will arrive on the Day of Resurrection saying there is no god but Allah, seeking the face of Allah by it, without Allah forbidding the Fire to him.”
Where this comes from
The clause in the middle is doing all the work. Not saying it. Saying it after something.
The full narration
Narrated `Utban bin Malik Al-Ansari:who was one of the men of the tribe of Bani Salim: Allah's Messenger (ﷺ) came to me and said, "If anybody comes on the Day of Resurrection who has said: La ilaha illal-lah, sincerely, with the intention to win Allah's Pleasure, Allah will make the Hell-Fire forbidden for him
Source
Ṣaḥīḥ al-Bukhārī · 6423
- Agreed upon as authentic (al-Bukhārī / Muslim)