Experimenting with scales
Start by picking a scale or mode (eg. C dorian).
Write out all the notes in that scale (C-D-Eb-F-G-A-Bb).
Now, on your piece of paper, fill up an entire line with random notes taken from that scale (C-Eb-G-A-D-F-Bb-C-Eb-F-G-Bb-D-C-Eb-Bb-A-G-F-A-A-Bb-D-C-F-A-D-Bb-C-C-A-Bb-C).
You’ve just created a melody! Play it on the guitar or piano.
Change some of the notes in your melody to make it sound better (C-Eb-G-A-D-F-Bb-A-Eb-G-Bb-D-C----Eb-Bb-A-G-F-Bb-Bb---D-C-F-Eb-D----).
You might still only like some of the melody you’ve created – keep that and cross out the rest (don’t rub it out completely as you might want to come back to it one day).
Now try adding chords to fit your melody.