Sen. Marco Rubio (R-Fla.) on Wednesday said he supports a law that would raise the age requirement to purchase a rifle, and would consider a ban of large-capacity magazines.

The father of a victim in last week's Florida school shooting asked Rubio during a CNN town hall event what he would do to work with parents, students and gun control advocates to prevent future violence.

"I absolutely believe that in this country, if you are 18 years of age you should not be able to buy a rifle. I will support a law that takes that right away," Rubio said.

He added that he supports banning bump stocks and improving the country's background check system, measures that have received support from the Trump administration and other lawmakers.

Later in the town hall, Rubio also announced he is rethinking his past support for large-capacity magazines.

"I'll tell you why," Rubio said. "Because while it may not prevent an attack, it may save lives in an attack."

Sen. Jeff Flake (R-Ariz.) said Wednesday he is working on legislation with Sen. Dianne Feinstein (D-Calif.) to increase the minimum age to buy a rifle.

Flake wrote in a tweet that he is "working with [Feinstein] on a bipartisan bill that will raise the minimum purchase age for non-military buyers from 18 to 21 - the same age you currently have to be to purchase a handgun."

During a listening session at the White House on Wednesday, a parent of a survivor at last week's high school shooting asked President Trump to impose age restrictions on gun purchases, saying if an individual can't purchase alcohol, they shouldn't be able to buy a gun. He also suggested arming teachers as a way of protecting students.

"If you had a teacher who was adept at firearms, that could very well end the attack very quickly," Trump said. "We're going to be looking at that very strongly. And I think a lot of people are going to be opposed to it. I think a lot of people are going to like it."

The NRA, however, came out in opposition to any new age requirements, saying it would infringe on the rights of law-abiding citizens.

Rubio during Wednesday's CNN town hall split with Trump on the matter of arming teachers when asked.

"I don't support that, and I would admit [it] to you right now. I answer that as much as a father as I do as a senator. The notion that my kids are going to school with teachers that are armed with a weapon is not something that, quite frankly, I'm comfortable with," Rubio said.

Rubio added that the idea has "practical problems." For example, in the middle of a crisis it could be unclear, if a teacher has a weapon, whether they are a threat, he said.

Students at Marjory Stoneman Douglas High School in Parkland, Fla., have spoken out in recent days after a gunman opened fire in their school on Feb. 14. The students have called on lawmakers to enact legislation that would curb gun violence and prevent school shootings.