God does not save unbelievers and unrepentant sinners.
Why do you think John the baptizer was beheaded?
It is never ever shameful to obey God.
Your false teachers told you that it is something called self righteous and wrong to obey God.
He believed in God and repented of his sins.
God only gives understanding to those who obey Him.
Psalm 119:100 I have more understanding than the elders, for I obey your precepts.
Proverbs 1:23 Repent at my rebuke! Then I will pour out my thoughts to you, I will make known to you my teachings.
Daniel 9:13 As it is written in the law of Moses, all this evil is come upon us: yet made we not our prayer before the LORD our God, that we might turn from our iniquities, and understand thy truth.
John 8:30 Even as he spoke, many believed in him. 31 To the Jews who had believed him, Jesus said, "If you hold to my teaching, you are really my disciples. 32 Then you will know the truth, and the truth will set you free.