Take it slow

When learning a new riff or other piece of music take it slow.

You should go so slowly that you play the right note every time — even if that means going painfully painfully slow.

The slower you go at first the faster you'll be able to go later.

As you begin to play a piece, you are programming your fingers, your "muscle memory" to be able to play that piece. If you play too fast and make even small mistakes, then you will begin to program those mistakes into your muscle memory. You'll find it impossible to avoid those same mistakes at faster speeds! So go slow... extra slow... really slow.

This is a rephrasing of the concept that music teachers bang on about: "practice makes permanent" (not that I've ever had a music teacher... I just hear about them). Allegedly basketball coaches also say this.