You have to read a lot so you know what good writing looks like and you get inspired. You have to write a lot because it's like a sport - you have to practice. And, also, you have to persevere. Don't give up. I got rejected on my first book, like, 14 times, but I just kept going. So believe in yourself and don't give up.
Rick Riordan