A "wicked" teenager used a catapult to fire objects at steeplejacks on a church roof, a court has heard.
Peter McRitchie, 19, from Milnathort, admitted endangering the lives of the two men.
He was part of a gang who brought "misery" to Milnathort with a catapult and BB gun, the court was told.
Sheriff Robert McCreadie called McRitchie's actions "disgraceful" and ordered him to do 180 hours community service.
Perth Sheriff Court heard McRitchie had fired his catapult at steeplejacks Craig Fox and Darren Slight on 3 October 2008.
Fiscal depute Stuart Richardson said: "A group of steeplejacks had been given the task of fitting mesh over church windows on the steeple of the church.
"They were working from chairs suspended in the air. Mr McRitchie fired the catapult on more than one occasion in the direction of the church.
"Thankfully they missed the steeplejacks, but they could hear the objects striking the steeple near where they were," he told the court.
The other members of the gang admitted earlier this year to using a catapult and BB gun to fire at children and passing motorists.
Robbie Lindsay, 17, from Glenrothes, was ordered to carry out 200 hours community service.
Adam Stirling, 17, from Milnahort, was fined £350 pounds and ordered to pay the same amount in compensation.
Sheriff McCreadie told McRitchie he had only narrowly escaped a custodial sentence.
He said of the gang: "People like these three cause misery in communities across the land by acting in an irresponsible, wicked and childish manner.
"They are publicly shamed for acts I consider to be wicked behaviour. They should put themselves in the position of the young child, the car driver or, extraordinarily, someone working on a steeple.
He added: "You should be thoroughly and completely ashamed."