A couple of tips on top of what wintersun and oprobrium have said (which is all true and doesnt need re-stating):
Slow down EVERYTHING until you are playing it at a speed where you are playing each and every note exactly how you want to. Be certain to pay attention to every beat and flinch of a string. If that means right down to where you are thinking about where to put each finger, so be it.
Then work up to the speed required with a click every step of the way. Play it at a speed that you feel close to able to play it at until you get it right, then keep playing it till you can get it right 10 times straight. Repeat.
Tip 2: drop your gain right down. No, further. Thats not it: FURTHER. Now layer it. Multitrack. 4 times, even more maybe. I doubt a single track of guitar has been used for a main riff in a well distributed metal album in.....ever. Its all at least double tracked. Most are a few different sounds added.
The lower gain lets the notes become more defined, and the layering gives thickness that you, as one guitar player with one guitar and one amp, normally use gain and big speaker cabs for. Layering at low gain really helps get that big sound out of small speakers (<12 inch! My speakers are 6.5 and 8 inch woofers and they cannot, according to the laws of physics, sound how a 12 inch guitar speaker does, let alone 4 in a cab. Work arounds are needed to get thick, heavy sounds out of smaller gear and layering is a big one),
But most importantly, in this case the act of layering it will force you to play it identically repeatedly, and encourage accurate picking and timing. At the very least play 2 tracks, pan one far left and one far right.
Recording is a big learning curve and a whole other dimension to playing guitar. It always comes with a learning curve. Recordable guitar playing is a cut or two above what sounds good to you when youre playing on your own. There are always suprises! Soon enough though, you'll listen to your playing with a much more accurate ear, trained by recording, and be massively better for it. Youre going in the right way: asking for advice and looking to improve your playing and recorded music 8)