A bungled break-in ended up with two would-be thieves locked in the offices of a Dunfermline school by an alarm system.

One of the culprits, Kieran Hamilton, also broke into a pub as well as stealing from unlocked cars.

Hamilton, 29, of Alma Street, Inverkeithing, and formerly of Halkett Crescent, Dunfermline, appeared for sentencing at Dunfermline Sheriff Court.

He admitted a series of offending.

On 25th August 2021 in Clerk Grove, Dunfermline, he entered an unlocked car and stole items including a pair of trainers, leggings, a debit card and money.

On the same day, he entered another car in the street and stole a dashcam and two pairs of sunglasses.

On the same day he was in possession of cocaine.

On 12th September 2021 he broke into the Barley Sheaf pub, Evershed Drive, with intent to steal.

Depute fiscal Andrew Brown said Hamilton and another man got into the bar with another man at around 1.45am. The alarm went off and they both ran out.

On same day, he was found in the curtilage of a house in Calais Burn Place, whereby it could be inferred he was intending to steal.

Also on the same day, he broke into Dunfermline High School with intent to steal, accompanied by another male.

The depute fiscal said the pair had forced open a door and went into the administration offices.

A locking system has activated when they were inside, police arrived and they saw the hapless pair looking out of a window.

Defence solicitor Stephen Morrison said his client had a Valium and cocaine habit at the time.

He added: “He is now embarrassed by his behaviour and finds it shameful.

“He would like to apologise to everyone involved. He has removed himself from that peer group, moved to another area and found a job.”

Sheriff Mark O’Hanlon imposed a community payback order with 200 hours of unpaid work and a year of supervision.

Hamilton was also ordered to pay a total of £500 compensation.