I may be pessimistic but I have never believed a law, or anything else less than armed guards will stop such occurances.
The mental health aspect is beaten to death. People snap all the time. Normal one week out of kilter the next. Nothing on the planet short of the ability to respond to violence with a return of swift overwheleming violence in return will stop a person bent on killing a bunch of people or one person for that matter.
Laws background checks etc do nothing. Even violent repeat felons can and will lay their hands on whatever firearm the want simply because they dont operate inside the system.
Attacks like these will happen. Thats the reality of life. The only question is do we disarm the innocent :which we have already done with gun free zones: so they are lambs at the slaughter or do we either allow them to have means to stop or mitigate these attacks. And/or put armed staff in place to meet an attack with a quick overwhelming response?
Life isnt fair, social engineering only makes things worse and after 200 years plus there are enough laws on the books about any and everything there shouldnt even need to be another law discussed on any subject.