I honestly think the best tip to (learn to) create melodies is to re-create existing melodies, all the time, 24/7, untill you do it in less than 2 minutes.
That's my way of doing it, I think there isn't really a "right" way to do certain things when it comes to making music.
I learned it because I used to make MIDI files for some forum back in the days, and I was always the first guy to upload a midi file of a certain song and then people would be all cool and happy and download that stuff.
Because of making midi files 24/7, I learned the piano roll thing really quick. I can write every melody in piano roll if I want to, and when I have something in mind, it's not a problem for me to find the right note. It became a habit over the years and i'm lucky to be able to create melodies this quick. No lessons, never played an instrument or whatever. Just made midi files. Thought this might be a good tip. It's also a really fun way to get insight on melodies and discover how they are made!
PS: don't use midi files. Do it yourself haha