How to Figure Out a Guitar Melody by Ear
Figuring out a melody by ear is a separate skill from figuring out chords (see [[how-to-figure-out-chords-by-ear:the article on chords by ear]]), but it starts exactly the same way - by finding the key, not by guessing the first note at random.
The key first, notes second
A likely key (see the article on finding the key) gives you a useful hypothesis: test the diatonic scale first and use the pentatonic as a narrower clue. Melodies often include the fourth and seventh, chromatic passing tones, or borrowed notes, so the scale should not become a ban on every other pitch.
Sing the phrase before hunting for it on the neck
Sing or hum a short piece of the melody a few times before picking up the guitar - your voice remembers the melody's shape (up, down, a leap) more accurately than trying to pick it out on the instrument right away. Search the neck for a specific phrase you're clearly holding in your head, not a vague 'something like this'.
Search inside one pentatonic position
For a first search, limit yourself to one scale or pentatonic position (see the article on getting started improvising) so you are not scanning the whole neck. If a note does not fit, test nearby diatonic and chromatic pitches before assuming the key itself is wrong.
Work backward from the end of the phrase
The last note of a phrase is often more stable than the notes before it, but it may be the third, fifth, another chord tone, or an intentionally unresolved pitch rather than the tonic. If that final note is clear, use it as an anchor and work backward without labeling it 'home' in advance.
Check one note at a time, not the whole phrase at once
Play one guessed note along with the recording and compare - only once it's confirmed exactly right should you move to the next. Trying to pick out the whole phrase 'by eye' tends to pile up small inaccuracies that are hard to find and fix individually afterward.
Pruébalo en la práctica
Open exercises