A Fife man tried to rape a 15-year-old girl after assaulting an older teenager, before telling the victims it would be their fault if he went to jail.
The older teenager found the younger one looking scared after her ordeal.
The High Court in Edinburgh was told the teenagers heard Aaron Hickman coming back and sat with their backs against a door to stop him entering.
Depute advocate Jane Farquharson QC said: “The accused was pleading with them not to tell anyone as he would lose his job.”
The older teenager told Hickman what he had done was wrong.
“He said it will be their fault if he went to jail,” said Miss Farquharson.
Hickman subsequently contacted them through Snapchat and begged them not to tell anyone.
However, the teenagers told their parents and showed the messages.
The police were contacted and Hickman was arrested at the RAF base at Lossiemouth, in Moray, in July.
Miss Farquharson said Hickman, 24, of Seafield View, Kirkcaldy, had signed up with the RAF in 2018.
He was working as a logistics supplier but was subsequently discharged.
Hickman admitted attempting to rape the younger teenager on July 7.
He also pled guilty to sexually assaulting the older teenager on the same date.
The court heard Hickman repeatedly apologised to them in messages after the assaults.
Miss Farquharson said: “He said he had not been able to control himself, that it had happened so fast and that he had not been thinking.”
The judge, Lord Uist, adjourned the case until July for the preparation of a background report on the offender, who has never previously been sentenced to imprisonment.
Hickman was put on the sex offenders register.