A British schoolboy described as a “model pupil” on Tuesday admitted robbing a bank while carrying a fake gun.

The 15-year-old, who cannot be named for legal reasons, held up a branch of Barclays bank in Liverpool, northwest England, on Friday and made off with £2,000 (about $3,200), the city’s youth court heard.

His mother turned him over to the police after finding a stack of cash and the fake weapon in his bedroom.

She wept at the back of the courtroom as her son, wearing a black suit, white shirt and tie, was led into the dock and pleaded guilty.

Judge Ian Lomax said the boy had acted almost as if he was playing a video game.

“This is a very serious matter,” the judge told the court.

“It’s an armed robbery, but not in the conventional sense most people would recognize. It’s a bizarre, surreal case of a young man almost acting like a real-life action video game.”

Prosecutor Debra Chan said the boy had walked into the bank with a scarf over his face, pulled out the gun and told cashiers: “Don’t do anything stupid. I have just got out of prison after five years.”

The cashiers filled the bag with a “dummy bundle” which is designed to spray dye over the cash when it leaves the building, Chan said.

“He wanted the money because he was envious of other people who had material things he wanted,” she added.

The court heard that the boy was a “model pupil” at school who was not known for misbehaving.

Defence lawyer Esther Leach said he came from a “very, very good family” and was doing “fantastically well at school”.

The boy pleaded guilty to two counts of robbery and one count of possessing an imitation firearm with intent to cause fear of violence, and was granted conditional bail.