all comments I see: it's either ONLY about guns or ONLY about (Islamic) terrorism
The asshole was on a watchlist by the FBI. Of course he shouldn't have been able to acquire a goddamned gun.
This is about hate and ease of gun ownership. Who gives a shit about religion.
I don't think anything could have been done and I'm pretty pro-gun control. His father mentions that the guy has apparently a history of getting really mad at gay dudes and his ex-wife who divorced him told the media after the attack that he was mentally unstable and would beat her. So it's clear he has a personal issue with gay dudes and a violent personality. That makes focusing on screening people of an Islamic background pointless as that would in no way solve the underlying issue but just make homophobic Muslims feel extra justification to carry out these attacks.
The other thing is that he was not convicted or charged with anything by the FBI and apparently there are like 9-10,000 people every year who are investigated by them for possible connections to terrorism (only ~hundred a year are actually doing anything though). I can't in my mind justify taking away an individuals rights to something when they haven't even been charged with anything.
I think the only two ways to have prevented this guy is for his ex-wife to have pressed charges against him back when they were together or for a massive change in laws on who can get a gun. There's nothing else I can think of.