I'm all up for trying to write my own songs and stuff, but I want to use a wider range of guitar keys and scales, and my guitar teacher either doesn't know how to use different keys and scales, won't teach, or hasn't got round to it yet, and if I look on the internet, I'm really confused by what different people and different websites are saying.

So my query is this: I have a basic set of lyrics, and an idea of what kind of riff I want - but how do I get this riff? And how do I put it together with the rest of my song?
I can help you out, but it would be nice if you were more specific, because all I can do is give you the general "rules" for doing what you are asking.

Music theory is best taught with examples, so I'm going to go with a song I like, and know well, AC/DC back in black. The main riff in this example consists of two parts that alternate, beginning with the first section, which has three chords and then a short melodic line, and then the second part, which also consists of the same three chords, but a different melodic line.

So, assuming you know what you want to do with what you have, let's talk about how it fits together in theory and practice.

The song back in black is in the key of G. Meaning we have these notes available to us: G, A, B, C, D, E, F#. These are the springboard from which we make our song. We then harmonize the notes of the scale to give us the potential chords available to us:
I GBD = G major
II ACE = A minor
III BDF# = B minor
IV CEG = C major
V DF#A = D major
VI EGB = E minor
VII F#AC = F# diminished (we won't really use this one so much here)

Ok so now we have all of our parts, now we see what was done.

The intro riff has an E5 (power chord), followed by a D5 and then an A major (or A5), then there is a riff which consists of a G, E, D, B, A, A#, A, B, G and ending on E.

Since this song is written with a minor tonality, the "root" here is the E making it the I, followed by the D (the VII) then the A (the IV). The riff descends along the minor E blues scale (outlining a G then resolving to E).

*whew* a lot of stuff to read there if theory is new to but stick it out for another paragraph or so and this will start to make sense.

So the question is: what can we learn from this section of this song? Well, we can learn that it is totally awesome. We can also learn that a I,VII,IV chord progression has a unique sound that, especially played with power chords, is very rock and roll.

What can you do with this info?

If you want to write a rock song and like the general sound of this song, you can take that chord progression and use it for your own ends! Now simply do this same sort of analysis with songs that you personally like and start gleaning their chord progressions. There are a few very common chord progressions, and all of them have been done to one extent or another, but you can use these as the basis for your own composition. Other examples of common chord progressions are the I,IV,V or the "every punk song ever" chord progression. Or a I, VI, II, V aka "every jazz song ever."

Ok ok, you say, I've got this much, but what next? Well for a standard song, which is usually verse, chorus, verse, chorus, bridge, chorus, you would need a chord progression for each section. So one for the verse, one for the chorus and one for the bridge.

To do this, you just take other chords from your harmonized scale, and mix them around until you like the sound of it. Then combine them together with notes pulled from the scale to make your melody and then bam. You've got your song.

It's worth mentioning that that is a ton of information, and you will likely be confused with bits of it. Not to worry, just take the concepts I've provided and google the hell out of them. There are tons of people more than happy to go in depth how exactly to harmonize a scale, talk about chord progressions or who will discuss how to utilize pentatonic or diatonic scales to construct a melody over a chord progression.

Happy writing!