Did you receive the Spirit by your own efforts to live according to a set of standards or by believing what you heard?
Galatians 3:2
The law is useless to save you. Before Christ came, people were expected to do exactly what the law said, but since no one could do that perfectly, sacrifices needed to be made. Their sins were too great and happened too often for them to be holy without some kind of sacrifice. And nothing is different now: you were saved not because you were so perfect and holy but because Jesus was your sacrifice. When you accepted that fact, you were immediately saved. Nothing you did, other than accepting him, saved you. Accepting him as Lord of your life is the foundation of all of your faith.
When he became your Lord he also gave you his Spirit, and that Spirit is what changes your life. A lot of times you mess up, you do what you don’t want to do, and you feel terrible. You wonder how to fix it, how to make it right. And sometimes you feel powerless to change, and that is true—sometimes you are powerless, but the Spirit is not. Remember, it’s through the Spirit that you were saved. And if he has the power to save you, he has the power to change you.
When you fail, don’t hate yourself, don’t fret, and don’t give up. Just remember what you did when you were saved and do it again: turn to him, confess your sin, and accept his forgiveness and cleansing. The ability to know the right thing to do and the strength to do it all come from the Holy Spirit who lives in you. Don’t try to do it all by yourself. Call on him, beg him, and trust him to make you more like Christ every day. When you fail, get up, wipe yourself off, and keep moving forward. You can do all things through him (see Phil. 4:13). Trust that and accept his forgiveness.