A drunken man was seen brandishing what looked like a handgun in Galashiels.
Thomas Cole had bought the imitation firearm from a toy shop, claiming it was intended for his mother to fend off burglars.
Forty-one-year-old Cole, of High Street, Yetholm, was sentenced to a six-month community payback order after he pleaded guilty to brandishing an imitation handgun in Channel Street and Market Street on October 15 last year.
Defence solicitor Mat Patrick said his client was “hanging around with a group of heavy drinkers and was drinking heavily himself at the time”.
The lawyer added: “He says he bought the gun from a shop opposite Jedburgh Sheriff Court and it is essentially a toy, although at first glance it does look like a real gun.
“He is aware that it was a stupid thing to do.”
Sheriff Kevin Drummond observed that an earlier narration of the facts stated the accused claimed to have bought the gun to give to his mother to fend off burglars, but that he offered it to her and she refused it.
The sheriff said Cole was described as an intelligent young man who had become associated with drink and drug users, and involved in extensive use of magic mushrooms.
Mr Patrick said his client had taken no alcohol or drugs for some time.
“He is trying to put the past behind him. He knows that this is behaviour which cannot be allowed to go on, and that serious consideration has to be given to custody,” he concluded.
Sheriff Drummond warned Cole: “Were it not for your well-established mental-health issues you would be going to prison. To be found in the street, waving albeit a toy gun, is a serious situation which could also give rise to a serious public order situation.”