She said the group opposed raising the legal age for purchasing an assault weapon to 21 from 18, an idea that Mr. Trump had earlier signaled support for. Students who are old enough to serve in the military should be allowed to own firearms, she said.

Diane Wolk Rogers, a history teacher at Stoneman Douglas, confronted Ms. Loesch by asking her to defend the idea that allowing the suspect in the shooting, a 19-year-old, to own an assault rifle represents “a well-regulated militia” as is written in the Second Amendment.

Ms. Loesch said the phrase was meant to protect the rights of anyone who “could operate and service their firearm,” an answer that drew loud yelling and more boos from the audience.

Mr. Rubio, for his part, had offered opening remarks that he clearly hoped would deflect criticism during the event. He expressed grief for those who were affected by the shooting, but he said that people in the United States needed to find ways to disagree “without accusing one another of being evil people.”

But the audience, including Mr. Guttenberg, did not hold back in criticizing Mr. Rubio’s position on gun control. Mr. Guttenberg repeatedly asked whether Mr. Rubio believed that “guns were the factor in the hunting of our kids.”

The senator said he agreed, but he insisted that other types of laws would better prevent such attacks. He said that he would support a bill to increase the minimum age for the purchase of an assault weapon to 21 from 18. And he said that he backed improvements to background checks and a ban on so-called bump stocks, which can convert semiautomatic weapons to fire automatically.

Students and teachers at the forum on Wednesday also had questions for Florida’s other politicians, including two Democrats, Senator Bill Nelson and Representative Ted Deutch.