TEXAS CITY, Texas—The school district here uses a facial recognition system to scan for people not allowed on school grounds. IDs track the whereabouts of students and staff. Teachers have cellphone panic buttons to alert police and soon will have special locks on classroom doors that can be activated remotely. A newly expanded security team keeps 22 AR-15 rifles in their offices.

The district has spent $6.3 million in eight months on these and other security measures to keep students safe from potential shooters.

“My...