You're jamming on a tune with some other people. You might be in the studio, or at a jam session, or just playing around with some friends. Suddenly, the leader points to you. It's time for you to improvise a solo, and you have no idea what to do.
Does this seem familiar?
Learning to improvise fluently (knowing exactly what you want to play and being able to play it in the same instant) is a life long study. There are no shortcuts to becoming a great improviser. However, there are some basic tips that will give you *something* to play in the mean time should the need arise.
There are three scales you need to know that will get you through most basic pop, rock, blues, and country situations. These are the Major Pentatonic, Minor Pentatonic, and Blues scales. Start by figuring out what key you're playing in, then proceed as follows:
Major Pentatonic - notes 1-2-3-5-6 of the major scale. (In C Major, C-D-E-G-A.) This will work over major key pop, rock and country tunes, as well as bluegrass and folk music.
Minor Pentatonic - notes 1-3-4-5-7 of the minor scale. (In A minor, A-C-D-E-G.) This will work over minor key pop, country (usually dark ballads) and rock tunes, as well as hard rock, punk, and metal. In a style that uses lots of power chords (punk, metal) and doesn't seem to fall squarely into major or minor, the Minor Pentatonic scale is usually a good bet.
Blues Scale - notes 1-b3-4-b5-5-7 of the major scale (In C Major, C-Eb-F-Gb-G-Bb.) This will work over the Blues, blues-rock tunes, and even some jazz tunes. It also works as an alternative to the relative major scale in some rock and pop situations. (For example: C blues scale over an Eb Major tune.)
Once you know what scale to play, start choosing some notes and see where things go. If you need some direction, I recommend the following. Play a note. (The tonic, 3rd, and 5th notes of the scale are always reliable choices.) Listen to how it sounds against whatever background is playing. Ask yourself: does this note seem to want to go up or down? By a short step or large leap? Pick another note from the scale that fits those instincts. Try it, then listen again, and so on.
Congratulations: you've just taken a solo.