First, read. Read a lot. (Stephen King, paraphrased – “if you don’t have time to read, you can’t write.”) Reading will teach you how to write, how to write well, and how to write compelling characters.
Corollary – read the genre you’re writing in, that will teach you the ins and outs of that genre, and it may inspire a story.
Second, are you a pantser or a plotter? If you’ve tried to write several books but haven’t been able to finish (pantsing), try writing an outline (plotting). If writing an outline kills the story for you, you’re a pantser, stop outlining and write the story.
Third, every good writer has dozens of starts and stops behind them. Some were completed. Some died in the writing. None of them were published. They were learning their craft. Learn your craft. If this is your first novel, put it in a drawer. Read in that genre. Come back to that book. It’s okay if you realize it’s crap. You write crap to become a better writer. Really good writers like Stephen King, wrote a lot, and started early. His first book “I was a Teenage Grave Robber” was independently published while still in high school. His first professional short story, “The Glass Floor” was published in a magazine.
Fourth, writers create worlds that might exist, have existed or exist only in the imagination. If you have to ask how to write a particular genre, you need to read more, see more movies, and use your imagination. Other writers write their stories. You have to write your own.
Fifth, write because you love it, because you have to do it, because you care about the story or the reason behind writing that story. If you’re not doing it because you love it, if you’re doing it for fame or money, you’re doing it for the wrong reasons. Most writers will not get rich writing. They might make money, but only a few get rich.
Corollary – if you can quit, if it’s too hard and reviewers are mean, if you’re not driven to write, you’re in the wrong business. Who told you this writing thing was easy? Whoever they were, they lied. If it’s too hard, stop complaining and quit.
Sixth – If you don’t feel it – love, heartache, joy, grief, whatever – your readers won’t. Care – about the characters, the story, and why you needed to write it. Tears in the writer, tears in the reader. Laughter in the writer, laughter in the reader. Fall in love with the character(s).
Seventh – who is/are your main character(s). What’s their history, what motivates them, what do they need, what do they have to overcome? (Think about your favorite novels and the characters in it.) Pantser know their characters, plotters learn them. Until the reader knows those characters and what they care about, they don’t know what the story is about, and they won’t care what happens to the people in it.
Eighth, write more books. The best writers in the world wrote multiple books. Some tried to publish their first ones and received rejection letters of varying types. The good rejection letters told them why it was rejected. Indie writers don’t have that, they have readers. If this is your first book, write at least two more, if not four more. Readers want to follow an author they love. Give them something to follow.
Ninth – If the story isn’t working ask yourself why you’re writing it? If you’re writing it for the money, or because it’s a popular genre, you’re writing for the wrong reasons.
Are you trying to force your characters in a direction the people you created won’t go? Then follow the logic. Every good writer has discovered a story where the characters say “oh, no, I am NOT going there” because it’s not true to or for that character. Always stay true to the characters you’ve created. A good guy doesn’t suddenly turn bad, there has to be a reason. A bad boy character doesn’t suddenly change his stripes in a novel any more than he would in real life.
Tenth, what’s the story you’re trying to tell? Why should readers care? What are you trying to say?
Eleventh, How do you write? There is only one way – Apply seat to chair and fingers to keyboard. Write the story. Don’t listen to the naysayers, the doubters, or your own insecurities (there’s no such thing as a secure writer, the best are insecure because it makes them question their writing). Just write.
Twelfth, show don’t tell. Characters do things. Show them doing, either by describing it, or have them say in dialog what they’re doing and why.
The story is done when the story is done, when the characters have said everything the reader needs to know. Don’t know the ending? Take a step back. Talk to your characters. Ask yourself how you want it to end. Write that. If you can’t, it’s likely that you’re pushing the story in the direction you want it to go, not the direction it wants to go.
More than anything else, though, write the story. Do it because you love it. You’re the only one who can write that story. The story is the only thing that matters.
Is there a guarantee that it will be a best-seller? No. But a book(s) can’t be a best-seller if it’s not written.