Most people under 21 will not be able to buy guns in California starting next year, under a law Governor Jerry Brown announced signing on Friday.

The law will prevent people under 21 from buying rifles and other types of guns. State law already bans people under 21 from buying handguns. The law exempts law enforcement, members of the military and people with hunting licenses.

It was one of dozens of bills on which Brown took action.

The Democratic state senator Anthony Portantino pointed to the shooting at a Florida high school earlier this year that killed 17 people as the reason for his bill banning gun sales and transfers to people under 21.

“I was determined to help California respond appropriately to the tragic events our country has recently faced on high school campuses,” Portantino said in a statement. “I feel it is imperative that California leads when Washington refuses to act.”

Despite the exception for members of the military, Craig DeLuz, a spokesman for the pro-gun Firearms Policy Coalition, said: “Governor Brown just told millions of people under 21 that they can fight and die for our state and country with machine guns, but they can’t buy a gun for self-defense in their homes. That’s nuts.”

Brown also signed a bill to prohibit gun ownership for people who have been hospitalized or otherwise placed on an involuntary psychiatric hold for risk of hurting themselves or others twice in one year. That law would let those people ask a court every five years to return their guns.

He also signed a bill to ban people with certain domestic violence misdemeanors from owning guns for life.

In addition to the gun-related bills, Brown vetoed a measure that would have let bars in some cities serve alcohol until 4am, which he said would result in more drunken driving. California currently lets bars serve alcohol until 2am.

“I believe we have enough mischief from midnight to two without adding two more hours of mayhem,” Brown wrote in his veto message.

The bill would have allowed extended hours in nine cities, including Los Angeles and San Francisco.

Brown also vetoed a bill that would have opened the door for parents to serve edible marijuana to their children on school grounds, to treat medical conditions. Children could be given cannabis only if the school board adopted a policy to allow it.

Brown said in his veto message he is concerned about exposing youth to marijuana and believes the bill is too broad, allowing its use for all ailments.

“I think we should pause before going much further down this path,” he wrote.