The boys are said to have murdered Craig Preston, 34, together with Shiraz Bashir, Leonie Mason and a third teen.
The first boy admitted punching Mr Preston three times before running away, Sheffield Crown Court heard.
All five defendants deny murdering Mr Preston, who was found dead last year.
The second teenager said he ran away when he saw Mr Bashir hit Mr Preston with the bar, the court heard.
More stories from across Yorkshire
Prosecutors allege Mr Bashir, 42, and Ms Mason, 24, both of Holme Park Court, Huddersfield, plotted to kill Mr Preston, also known as Craig Nelson, because he was an "annoyance" to their relationship.
Mr Preston, who was also in a relationship with Ms Mason at the time, was beaten to death in a "brutal and senseless" attack before being dumped near the Woodhead Tunnel on 21 August, prosecutors have told the court. His body was found the following day.
Reading from a police interview, barrister Andrew O'Byrne QC said his client - the second boy - told officers he had been asked by the first boy to accompany him to a lay-by in Rotherham where the attack took place.
"He told me he had to do it," the boy told police.
"He told me that and asked would I come with him. I said 'Yes, because I want to know you are safe'."
The boy told police his friend had told him he had been "threatened" by Mr Bashir to take part in the attack.
He said that in the lay-by "Bashir opened the [car] door, grabbed [Mr Preston] and I jumped out and [the other boy] jumped out.
"As soon as I saw [Bashir] with a metal pole we just decided to chip and run."
For the first teenager, Aftab Jafferjee QC told the jury in his closing speech there was no "single rational motive" for his client to take part in the fatal attack on Mr Preston "if it was voluntary".
"We submit that whatever moral aspect there is for hitting [Mr Preston] he simply, on the evidence, is not guilty of murder or manslaughter and, in any view, this case does not come within a country mile of murder," he said.
The trial of Mr Bashir and Ms Mason and the three teenagers, who cannot be named due to their age, continues.
Two teenagers accused of being part of a plot to kill a man told police they fled after seeing another man strike the victim with a metal bar, a court heard.