(CNN) A teenager was en route to an Indiana middle school Thursday to commit an act of violence, but police were able to stop him after receiving a tip, state police said.

The 14-year-old exchanged gunfire with police at Dennis Intermediate School in Richmond before killing himself, Indiana State Police Sgt. John Bowling told reporters, citing preliminary results of an investigation.

"Someone knew something, and they said something," the sergeant said, attributing the fact that no students were hurt to the tipster.

Richmond Community Schools received the tip, notified police and put all of its schools on lockdown before the police or gunman arrived, district spokeswoman Bridget Hazelbaker said.

Richmond police alerted area law enforcement to the potential for violence at Dennis Intermediate, state police said in a statement, and when officers arrived they confronted a teen "who then reportedly shot out the glass of a locked entry door to the school, and ran inside with police officers in pursuit."

Read More