The 14-year-old boy arrived at Sycamore Middle School Wednesday morning ready to carry out a deadly plan.

But there was one person he knew could talk him out of it, according to police. So after his first-period class at the school in Ashland, Tenn., he went to see her.

Molly Hudgens, the school counselor, took the boy into her office and immediately sensed something was wrong. He asked some questions Hudgens found alarming and told the counselor he was having “issues,” police said. 

Do you have a gun? Hudgens asked.

Yes, he said, and showed her the loaded .45 caliber pistol tucked under his clothes. He told her he wanted to kill teachers and a police officer, The Tennessean reported.

Just hours later, on Wednesday afternoon, a different 14-year-old boy in South Carolina would open fire on an elementary school playground, injuring two children and an adult.

But Sycamore Middle School avoided such tragedy. After a 45-minute conversation in her office, Hudgens persuaded the teen to give up his gun, Cheatham County Sheriff Mike Breedlove said Wednesday.

“She did something even the most experienced law enforcement officer might not do,” Breedlove said. “Had she not been there, it could have been very different.”

The boy, who has not been identified, was arrested and charged with possession of a weapon on school grounds and threatening employees. He is being held in a county jail pending his next hearing.

What happened at Sycamore is rare. In most school shootings in recent memory, gunmen have attacked without clear forewarning, and guidance counselors, friends or family members are seldom given a chance to step in and stop them. In Wednesday’s shooting in South Carolina, authorities say the gunman killed his father before opening fire at the school.

People in the community have hailed Hudgens as a hero.

Hudgens, who said she’s been with Sycamore for almost 19 years, wasn’t available for comment Thursday night. But in a video statement released by the Cheatham County School District, she called the boy a “student in need” and said that her training in deescalation helped her persuade him to hand over the weapon. She said the boy didn’t name any specific students or teachers as targets.

“Sycamore Middle School is safe,” she said. “I’m proud of the actions of our faculty, staff and students … in maintaining an atmosphere of calm.”

In a news conference Wednesday, Breedlove said the boy brought the gun from home but he declined to comment on what problems prompted him to take it to school. During the conversation in her office, he said, Hudgens tried to discreetly text security to let them know about the situation, but she couldn’t get a clear signal from inside the room. When she did notify police, Sycamore Middle School and a neighboring high school were placed on lockdown. Breedlove said the gun never left her office until police arrived.

It was Ms. Hudgens that defused the whole situation,” he said. “She had a lot on her shoulders.”

On her school profile page, Hudgens says she started working at Sycamore in 1999 and joined the counseling department in 2006. She says in her bio that she hopes students find the counseling department to be a “warm environment” where they can go for “advice, direction, and encouragement.”

Jessica Williams, a friend of Hudgens, told the Associated Press that she wasn’t surprised by Hudgens’s actions Wednesday.

“She’s the type of person that would be easy for her to get through to somebody,” Williams said. “She’s a very loving, caring, motherly personality.”