In order to determine exactly where to place your first finger to start a scale in a particular key# it is essential to know the notes on the sixth string from memory. The diagram below illustrates these up to the 13th fret, where the F note repeats an octave (eight notes) higher than the first fret. After this, all the other notes repeat as well.
The examples below demonstrate some riffs derived from the minor pentatonic scale in different keys. Once you can play each one, play it in different places up and down the fretboard, making sure you know which key you are in each time you move to a different fret. The note under your first finger on the 6th string will tell you the name of the key.