I've sinned and then tried to pray about a pressing problem. I couldn't pray. I didn't feel close to God. I didn't feel like I deserved to go to God with my problems. I needed to repent and return to God with all my heart. 1 John 3:21 22 says Dear friends, if our hearts do not condemn us, we have confidence before God and receive from him anything we ask, because we keep his commands and do what pleases him.
James 4, verses 7 to 10 Submit yourselves unto God. Resist the devil and he will flee from you. Come near to God and he'll come near to you. Wash your hands, you sinners, and purify your hearts, you double minded. Humble yourself before the Lord and He will lift you up when we approach God with sin in our lives, we have no confidence.
It affects our faith. Our consciences bother us. We need to get rid of our sin to boldly, with great faith, approach God for help. Hebrews 4:16 says, Let us then approach God's throne of grace with confidence so we may receive mercy and find grace to help us in our time of need.
It is our faith that gives us victory. 1 John 5:4 for everyone born of God overcomes the world. This is the victory that has overcome the world. Even our faith.
When Sin Keeps You From Praying: How to Return to God