Name the archetypal character who fits this description: a selfish loner who has noble motives, but is flawed in some way
The correct answer should be the anti-hero
It does not mean that the person is not a hero, but rather that it often does not behave as a hero, but ultimately means well and wants good to happen. It could be described as a rogue with a heart of gold.