Those in Matt 7:21-23 were citing their works as evidence of their faith. Jesus said no go. But they definitely believed their good works were evidence for their faith.
They said that they had good works, but did they really? Again on this Jesus gives the answer. Here let us post it so that we are sure.
Matthew 7:21-29
21 Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven.
22 Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works?
23 And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.
24 Therefore whosoever heareth these sayings of mine, and doeth them, I will liken him unto a wise man, which built his house upon a rock:
25 And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell not: for it was founded upon a rock.
26 And every one that heareth these sayings of mine, and doeth them not, shall be likened unto a foolish man, which built his house upon the sand:
27 And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell: and great was the fall of it.
28 And it came to pass, when Jesus had ended these sayings, the people were astonished at his doctrine:
29 For he taught them as one having authority, and not as the scribes.