All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
The basic principle set by scholars in this regard is that the Muslim ruler is entitled to lay restrictions on some matters, which are lawful in principle, in order to realize the public interests of the Muslims.
As for carrying weapons in school by students, the benefit realized by putting a ban on such an act is evident as it helps protecting young children from the evils of weapons and eliminating the potential evil of abusing them.
Abu Moosa narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said, “Whoever enters our mosque or passes through our market with arrows should hold them by their heads lest they injure any of the Muslims.” [Al-Bukhari and Muslim]
It is deduced from this hadeeth that precautions should be taken lest Muslims would be injured accidentally. Then what about children carrying weapons at school knowing that such weapons may take lives in a second, unintentionally sometimes?
Allah knows best.