Updated

Nikolas Cruz is just the latest U.S. mass shooter to legally obtain and own guns because of limited firearms laws, lapses in the background check process or law enforcement's failure to heed warnings of concerning behavior.

The 19-year-old had made threats and was expelled from school, bragged about killing animals, posed with guns on social media and went to a clinic for mental health treatment before took an AR-15-style rifle he had bought legally to a Florida high school and killed 17 people.

The same style weapon has been used in Sutherland Springs, Texas; Las Vegas; San Bernardino, California; and Newtown, Connecticut. A similar rifle was used in Orlando.

President Donald Trump kept a loophole allowing people to obtain guns while undergoing mental health treatment that President Barack Obama had tried to close. Other mass shooters have gotten around restrictions by using weapons initially purchased legally.

A look at some recent mass shootings, the number of deaths and how the attackers obtained their guns:

___

PARKLAND, FLORIDA: FEB. 14, 2018. 17 DEAD

Cruz legally purchased a Smith & Wesson M&P 15 rifle in February 2017 from a licensed gun store located about 3 miles (5 kilometers) from the school, law enforcement officials said.

Cruz had gone to a mental health clinic for treatment but hadn't been there in more than a year, Broward County Mayor Beam Furr said. Under federal law, gun purchases can only be blocked if a person is legally declared a "mental defective" or committed to a mental institution.

If Cruz wanted a handgun, however, the sale wouldn't have been allowed. Federal allows people as young as 18 to buy semi-automatic weapons from licensed dealers. Handgun purchases are restricted to 21 and older.

Cruz had his gun for about seven months when he commented on YouTube that he was "going to be a professional school shooter." The FBI said it investigated but was unable to identify the person who posted the comment.

In January, the FBI received a tip from someone who said Cruz had expressed a desire to kill people, was making disturbing social media posts and could potentially commit a school shooting.

The agency failed to follow protocols and no further investigation was conducted.

___

SUTHERLAND SPRINGS, TEXAS: NOV. 5, 2017. 25 DEAD

Devin Patrick Kelley's history of domestic abuse barred him from legally buying guns, but he did so anyway because information about his crimes was never entered into a federal database used for background checks.

Kelley purchased four guns, including the AR-15-style rifle and handguns found in and near First Baptist Church, from licensed dealers in Texas and Colorado over a four-year span.

The 26-year-old passed required background checks because the Air Force never informed the FBI about his criminal conduct - an assault on his wife and her child that led to a court-martial, a year of confinement and a bad conduct discharge.

Military rules require that the information be shared.

A 1996 law bans people convicted of even a misdemeanor-level domestic violence offense from owning guns. Kelley was convicted at a court-martial for choking his then-wife and fracturing her son's skull in 2012.

___

LAS VEGAS: OCT. 1, 2017. 58 DEAD

Stephen Paddock amassed the bulk of his arsenal over the span of a year, culminating with a purchase three days before he holed up in the Mandalay Bay hotel and opened fire on a country music festival below.

Paddock purchased 33 of the 49 weapons found in the hotel room and at his homes between October 2016 and Sept. 28, 2017, according to the Bureau of Alcohol, Tobacco, Firearms and Explosives.

None of the purchases drew scrutiny because the 64-year-old Paddock passed all background checks. His gradual accumulation of weapons went undetected because federal law does not require licensed gun dealers to alert the government about rifle purchases.

Twelve of the semi-automatic rifles recovered by authorities were equipped with bump stocks, a device that allows them to fire repeatedly without pulling the trigger over and over.

___

ORLANDO, FLORIDA: JUNE 12, 2016. 49 DEAD

Omar Mateen purchased an AR-15-style rifle, a Sig Sauer MCX, and a handgun on separate days about a week before the attack from a licensed dealer near his home in Fort Pierce, Florida. The 29-year-old passed a background check and had two security licenses, one of which allowed him to be armed while on duty.

The FBI investigated Mateen in 2013 and 2014 after co-workers shared concerns about statements he had made concerning possible ties to terrorist groups. Neither inquiry led to criminal charges. Even if he had been placed on a terrorism watch list, Congress in 2015 rejected attempts to prevent people on the list from purchasing guns.

___

SAN BERNARDINO, CALIFORNIA: DEC. 2, 2015. 14 DEAD

Syed Farook and his wife used weapons that the FBI said were legally purchased by his neighbor, Enrique Marquez, from a licensed dealer in 2011 and 2012. Marquez, who pleaded guilty to charges he conspired to provide support to terrorists and made false statements to acquire a firearm, told investigators that Farook asked him to buy the weapons because he would draw less attention. At the time, the FBI said, the men were plotting to shoot up a community college and a highway.

___

ROSEBURG, OREGON: OCT. 1, 2015. 10 DEAD

Christopher Harper-Mercer and his family members legally purchased the handguns and rifle he used in the Umpqua Community College shooting from a federally licensed gun dealer, according to the Bureau of Alcohol, Tobacco, Firearms and Explosives.

___

CHARLESTON, SOUTH CAROLINA: JUNE 17, 2015. 9 DEAD

A drug arrest should have prevented Dylann Roof from purchasing the pistol authorities said he used at Emanuel AME Church, but a record-keeping error and background check delay allowed the transaction to go through. The FBI said a background check examiner never saw the arrest report because the wrong arresting agency was listed in state criminal history records. After three days, the gun dealer was legally permitted to complete the transaction.

___

WASHINGTON, D.C.: SEPT. 16, 2013. 12 DEAD

Aaron Alexis, a former reservist turned civilian contractor, passed state and federal background checks and legally purchased the pump-action shotgun used in the Washington Navy Yard shooting despite a history of violent outbursts and recent mental health treatment. Alexis was accused of firing a gun in anger in Texas in 2004 and in Seattle in 2010 but was not prosecuted in either case. In 2011, he received an honorable discharge despite bouts of insubordination, disorderly conduct and unauthorized absences. None of that would have disqualified him from purchasing a weapon.

___

NEWTOWN, CONNECTICUT: DEC. 14, 2012. 26 DEAD

Adam Lanza used his mother's weapons, including a .223-caliber semi-automatic rifle, in the massacre at Sandy Hook Elementary School. Lanza's mother, whom he fatally shot before going to the school, also purchased the ammunition, investigators said.

___

AURORA, COLORADO: JULY 20, 2012. 12 DEAD

James Holmes was receiving psychiatric treatment when he passed required federal background checks and legally purchased the weapons he used in his movie theater assault. As in the Parkland and Navy Yard cases, treatment alone did not prevent him from buying guns.

___

AP reporters Kelli Kennedy in Parkland, Florida, Michael Balsamo in Los Angeles and Sadie Gurman in Washington contributed to this report.

___

Follow Mike Sisak at twitter.com/mikesisak

___

For complete coverage, click here: https://apnews.com/tag/Floridaschoolshooting