What am I doing wrong?

So I’ve been interested in this guy for a while he started off as a really good friend met last year and I started to develop feelings. I thought he felt the same, had loads of people around me telling me he was into me and that I should seriously consider it. I’m a total dunce with relationships and this would be my first. We’ve gotten more flirty and close lately there was a discussion a few weeks ago where he basically said he wasn’t looking for a relationship now because his head wasn’t in the right place but he wouldn’t say never to it. I was perfectly happy with that. Completely understood he needed to be 100% in himself before entertaining the idea of relationship but recently he seemed to be acting like more than a friend so I started to think that maybe he was open to it. I then get told by him today that he still isn’t in the right place to be with anyone and he doesn’t see us ever being more than friends. I feel like my hearts been ripped out and I don’t know what I’ve done wrong.