Melodies can seem really hard to invent, but it's actually quite easy if you go about it the right way. Listen to the start of Beethoven's Fifth Symphony on YouTube (https://www.youtube.com/watch?v=_4IRMYuE1hI) and you can notice how he's taken two notes, repeated the first one then gone to the second, and just repeated that pattern down some more pitches. That's called sequencing. Try finding two or three notes in one pattern, just playing about with a piano, then repeat the pattern up or down a few tones, maybe reverse the pattern of notes or rhythms, and eventually you should be able to find a melody you can use as a motif to build around.