You keep people around who motivate you. This doesn't mean they have to be successful themselves, it just means they aren't the kind of people that drag you down.
Even someone you may consider a good friend may be in the habit of giving you six baseless reasons something won't work for every solid reason you know it will, but this attitude still sows seeds of doubt in your mind whether you know it or not, and when things get difficult, those seeds grow and occupy space where confidence should be.
It isn't any better if you have a friend who is always down on his luck. He may be as encouraging as he can be, but if you've never seen him improve anything on his own, his words are meaningless, and again seeds of doubt are sown because even though he never intended it, somewhere in the back of your mind you're thinking "if all this bad luck can happen to him, can it happen to me too?". Now you're believing in luck, forgetting all the tips and advice you've sent his way that he ignored, or made excuses for why he didn't listen to you.