By Trang Do

UPPER GWYNEDD TOWNSHIP, Pa. (CBS) — Tense moments in Montgomery County after a man who police say was under the influence of drugs fired a shotgun at a police officer. Eyewitnesses in Upper Gwynedd told CBS3 the man was trying to get into homes and even confronted a woman in her car.

What started out with 911 calls for a suspicious man roaming an Upper Gwynedd neighborhood ended in a close call for one police sergeant.

“At which point, the subject turned around, sees Sgt. Royds, yelled obscenities and pointed a shotgun at him and fired it at a distance of approximately 30 feet away directed at Sgt. Royds,” Upper Gwynedd Township Police Chief David Duffy said. “Somehow that shot missed him.”

Officers were eventually able to take the 35-year-old white man into custody without anyone getting hurt. It all happened next to the Cabots’ home on Cathys Lane.

“I just saw a guy come running out from over here, and he had a gun and he shot it,” Julie Cabot said, “and I was putting trash out and I put it down and went back in and the cops came and told me to stay in.”

Before officers were able to catch up to him, neighbors say the man tried to get into their homes and sheds and one woman’s car.

“I just came home from the grocery store, I was in my car and a man came charging across from over here from my neighbor’s house and wanted to get in my car,” the woman said. “He kept saying, ‘can I ask you a question? Can I ask you a question?’ and I was like ‘no, absolutely not’ and I locked my car doors.”

Duffy says the man was under the influence of methamphetamines. In addition to the shotgun fired at the officer, police also recovered a Ruger rifle and extra ammunition.

“Certainly, it’s an extremely scary situation,” Duffy said. “I’m very glad that somehow that round missed the officer and also glad that they were able to safely take him into custody without anyone in this crowded neighborhood hurt.”

The man’s name has not yet been released. He’s currently at Lansdale Hospital undergoing detox. He was be charged once released.