Four teenagers tried to carjack a driver’s Mini when he stopped at traffic lights in Dewsbury, a court heard.
The gang, who all had their faces covered, surrounded the vehicle shortly after 3pm on January 28.
Kirklees magistrates were told that the driver was stopped at red lights at the junction of Challenge Way and Leeds Road.
Prosecutor Vanessa Jones said that the group - one in possession of a metal bar - approached the black Mini Cooper and banged on the windows.
She told magistrates that the driver and his male passenger were fearful that they would take the vehicle but they were unable to get inside as the doors were locked.
Four teenagers appeared in a secure dock flanked by three security officers charged with attempted robbery.
They were Ryan Morritt, 18, of Field Lane in Batley, and Mohammed Raja, also 18, of Carr Side Crescent in Batley.
They were joined in the dock at the Huddersfield court by a 16-year-old from Batley and a Deighton teenager, 17, who cannot be named for legal reasons.
Magistrates sent their case to Leeds Crown Court, where they will first appear on March 6.