As said above u can find the key by looking at the first cord which is often the first degree.It works most of the times but u can also be helped, if u got the part, by the signature at the beginning.I f u have one #, it's the key of G major, 2 # u're in D major... 6 # u're in f# major( it's easy to remember it's a fifth progression: G,D,A,E,B, F#).U could have more #, but generally u'll have b at the signature, it's easier to write. Same stuff: 1 b = F maj, 2 b = Bb maj.....6 b = Gb maj it's a forth progression : F,Bb,Eb,Ab,Db,Gb). But there are also what's is called the relative scales G maj and E min contains the same notes. If u wanna go further notice that the G maj notes can also belong to A Dorian, B phrygian, C lydian.....
By using what is above, u can use for the melody the notes from any the scales using the G maj notes but also the G maj pentatonic scale, why not G min pentatonic scale if u wanna sound bluesy or if u wanna sound a bit weird: g maj harmonic or melodic scales...the possibilities are infinite...just listen and enjoy.
Darkangel