Is buying a flat a bad investment?

Hi all,

Just after some opinions and advice, I’m looking at buying a property and for context the town I live in is quite expensive.

Due to this I can only really afford a flat or smaller terrace houses, I have been told buying a flat is risky as they can be hard to sell, would anyone agree with this?

I can understand why that may be but I have also considered that if I buy a flat I could potentially rent it out later down the line and then buy a bigger property with my partner. But any opinions are welcome.