Jesus says, “If you continue in my word, then you are really my disciples.” And He warns that on Judgment Day many will call out to Him,”Lord! Lord!” but He will say, “I never knew you,” thus pronouncing eternal punishment on those who did not follow His words. You cannot fool God by living as the ungodly do and convincing yourself that it’s acceptable to Him.
Actually, in context, scripture says:
Many will say to me on that day, Lord, Lord, did we not prophesy in your name and in your name drive out demons and in your name perform many miracles? 23 Then I will tell them plainly, I never knew you. Away from me, you evildoers!
The folks here were depending on their works to avoid judgement, not on the atoning sacrifice of Christ and the mercy of God.