California has some of the most restrictive gun-control laws on the books as it is, and still failed to stop the shooting.
The red-flags regarding mental health were flown, seen, and called into the police regarding the incident in question. Still, the police did not prevent it, and it almost doesn't matter why they did not.
Trying to stop a premeditated act by a human via a static defense like the Law simply will not work because, as we have seen, those with the determination to die in order to cause great destruction will plan around these laws until it's time to act.
Edit: Just to add, there is no clear evidence that gun control or legal gun ownership contribute significantly to overall violent crime rates either way. That fact raises a question as to why some politicians so desperately want to strip firearms from the population.