The thing I found best was to learn some scales and then play along with some CDs. Just play around until you find the right key and then keep experimenting, you'll soon discover what sounds good and what doesn't. There's no real rules so just keep on trying different stuff!
Another method that works well is to learn some solos or melodies from songs you like and you'll see how the riffs fit over the chords.
I started off by learning the pentatonic scales as they only have 5 notes and fit over most contemporary music! Then you can just keep on experimenting and learning more interesting scales and how to work with more complex backings.
A good online guide to scales is here:
scalefinder.info
It's a site that shows all the positions for scales and modes, just choose the scale and the key and it'll show you which notes to play!
Whats the best way to learn Pentatonic scales? For major scales I just start with a bar chord and play all the notes and move from there and seem to be able to pick up the scale easily from there, but the pentatonic scale takes some notes out. Is it best to just memorize it and play some songs written on Pentatonic scale, or are there any tricks in knowing what notes to skip?