CHESTERFIELD, Va.-- An off-duty police officer shot and killed a teenage boy in Virginia after the boy allegedly pulled out a gun during the sale of an Xbox, authorities said.

The shooting occurred about 12:30 a.m. Monday in the parking lot of a shopping center in Chesterfield County, a suburb near Richmond.

Chesterfield police Major Frank Carpenter said the off-duty officer was an associate of a man who had agreed to sell the electronic gaming system to the teenager in the parking lot of the Chestertowne Shopping Center.

Get Breaking News Delivered to Your Inbox

Carpenter said there was an exchange of gunfire between the officer and the teen when the boy pulled out a pistol. "It was an attempted robbery by the juvenile," he said.

The officer, who was not wearing his police uniform, was shot in the torso but his wounds were not life-threatening. He was treated at a hospital and released.

The boy died at the scene. Their identities were not immediately released. No one else was injured.

Police told CBS Richmond affiliate WTVR that the sale was arranged by a third-party on social media.

"I've only been teaching here for a few months but what I've heard and what I've learned from the administration, and from other teachers is that the area is not considered safe. We practice lockdown drills regularly to prepare for the unknown," Josie Schmidt, a teacher at Beulah Elementary School, told WTVR.

Another resident, Tiffany Abed, said she was "shocked" because incidents like the shooting "don't usually happen" in the area.

WTVR reports that authorities are asking anyone with information to contact the Chesterfield County Police Department at (804) 748-1251 or Crime Solvers at (804) 748-0660.