Absolutely, but the US have a gun culture that is in direct conflict with this sound proposal.
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.