Different histories, reliance on different industries, quality of transport links make a huge difference.
Not even all coastal "tourist" towns are doing badly - I live near Burntisland in Fife which actually seems to be thriving, probably because of the excellent location for commuting by train into Edinburgh, combined with nice beaches, great views (of Edinburgh!)...