The laws we have clearly aren't working, then. So: Better gun laws. Background checks. No guns for mentally unstable folks, or folks living with mentally unstable folks.
Another measure would be to raise the punishment for being an accessory, according to https://www.sandyhookpromise.org/blog/gun-violence/16-facts-..., at least one other person had knowledge of the attacker’s plan in 80% of the cases.
I don't think metal detectors or more surveillance at the school will help enough.
But implement the first two measures as a start.