CROWN HEIGHTS, Brooklyn (PIX11) – A teenage boy was trapped inside a vault in an old factory building in Brooklyn for close to an hour before being rescued Thursday night, authorities said.

The teenager and some friends snuck into a vacant building at 960 Franklin Avenue in Crown Heights around 10:30 p.m., FDNY officials said. The teens were messing around when one of them became locked behind a door in a vault in the building, according to authorities.

Another teen remained at the scene and showed an FDNY rescue team where to find the trapped boy.

“We had a small hole and we were able to talk to the kid inside the vault. He was breathing. He was fine,” FDNY Battalion Chief Tim Gimpel said. “We were in constant contact with him throughout.”

The FDNY rescue team used a saw and torch to break away at the thick steel of the vault’s door. Other rescue members used a sledgehammer to break through the wall.

They were able to rescue the boy after about 40 minutes, authorities said. The teen was not hurt during the incident.

FDNY officials warned the public against entering abandoned buildings in New York City due to potential hazards inside.

“Whenever we have a locked building, a vacant building like this, there’s always dangers inside. Children should not be playing inside these buildings. They are locked up for a reason. They are in a state of disrepair and there could be dangers inside,” Gimpel said.