I think it was a black and white film, made in the same kind of style as High Noon.
I think it starts with outlaws robbing a town, they might have killed some people too. As they are riding away someone picks up a pistol and fires a lucky shot which kills one of them. He is not a gun fighter and it was blind luck.
He is hailed a hero.
The town find out that gang are coming back and he become a pariah. ISTR he seems oblivious to the danger he is in and does not seem to realise why no one will allow their children near him etc.
The gang kill someone who helped him and later come into the town to kill him but still no one helps him. At the finale the gang are walking down the street towards the hero as he is firing at them but he keeps missing as he has no idea how to accurately fire a gun.
When I try to Google it, I just get references to High Noon (It is definitely not, I have seen both) or various other films and I cannot separate the wheat from the chaff!
Can anyone help?