It should be noted that truthfulness is a means of salvation in this world and in the Hereafter, and lying is a cause of doom.
Muslim (2607) narrated that Ibn Mas‘ood (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “I enjoin you to be truthful, for truthfulness leads to righteousness and righteousness leads to Paradise. A man may continue to tell the truth and endeavour to be truthful until he is recorded with Allaah as a speaker of truth. And beware of lying, for lying leads to wickedness and wickedness leads to Hell. A man may continue to tell lies and endeavour to tell lies, until he is recorded with Allaah as a liar.”
Rather people cite the riddle mentioned in the question to refer to the Jews and Christians. The Jews said that the Christians follow nothing, and they told the truth but they entered Hell. And the Christians said that the Jews follow nothing, and they told the truth but they entered Hell.
They narrate this from the Sufi Abu Yazeed al-Bastaami in the famous story in which some of the Christians asked him this question and he gave them this answer, quoting as evidence the verse in which Allah says (interpretation of the meaning):
“The Jews said that the Christians follow nothing (i.e. are not on the right religion); and the Christians said that the Jews follow nothing (i.e. are not on the right religion); though they both recite the Scripture. Like unto their word, said (the pagans) who know not. Allaah will judge between them on the Day of Resurrection about that wherein they have been differing”
It may also be said that this applies to the kuffaar of whom Allah said (interpretation of the meaning):
“And verily, if you ask them: ‘Who created the heavens and the earth? Surely, they will say: ‘Allaah (has created them)’”
“Say: ‘In Whose Hand is the sovereignty of everything (i.e. treasures of everything)? And He protects (all), while against Whom there is no protector (i.e. if Allaah saves anyone, none can punish or harm him; and if Allaah punishes or harms anyone, none can save him), if you know?’
89. They will say: ‘(All that belongs) to Allaah.’ Say: ‘How then are you deceived and turn away from the truth?’”
[al-Mu’minoon 23:88, 89].
And there any many similar examples. Some of the kuffaar may speak the truth in some of the things they say, but they will enter Hell because of their kufr, not because of their speaking the truth.
Whatever the case, it is not appropriate to say things such as this, because some people may understand from it that these people will enter Hell because of the truth they speak, but this is undoubtedly false. Allaah says (interpretation of the meaning):
“Allaah will say: ‘This is a Day on which the truthful will profit from their truth: theirs are Gardens under which rivers flow (in Paradise) — they shall abide therein forever. Allaah is pleased with them and they with Him. That is the great success (Paradise)’”