Cops investigate the scene where four people were shot dead and three others were shot, but survived, in Brooklyn.

Gamblers, hundred-dollar bills and bullets went flying when an after-hours dice game devolved into a chaotic shoot-em-up in Brooklyn early Saturday, leaving four dead and three others shot.

At least 15 rounds were fired at the Triple A Aces catering hall on Utica Avenue in Crown Heights.

When the gunsmoke cleared just before 7 a.m., one revolver, one 9 mm handgun and four bodies were left behind.

The three people rushed to hospitals with gunshot wounds were expected to survive.

One was identified by law-enforcement sources as Jachiyah Holder, 35, a state correction officer who was shot once in the leg.

The dead included Chester Goode, 37, a gambler who sources believe sparked the shootout by pulling the handgun and firing into the ceiling — in what was either a robbery, or, more likely, a beef over a game.

A single gunshot wound to the head ended his life.

Two pals he had brought with him — Terrence Bishop, 36, and John Thomas, 32 — also wound up dead, sources said.

So too did the illegal gambling den’s revolver-toting security guard, who’d heroically tried to stop the violence by firing at Goode, the sources said.

“The cops told me they died with their guns in their hands,” the property’s owner, Samuel “Sammy” Revells, told The Post, of Goode and the guard.

“It’s a real bad-ass situation we have here — bad for everyone,” he said.

It was unclear whether Goode was upset over his gambling luck or had come to the club intending to steal cash, sources said.

“The three guys had been playing for more than an hour, and they were losing money,” a law enforcement source told The Post of Goode and his pals.

“There was some big money there, even though it was a crime scene, there were some hundred-dollar bills still lying on the floor.”

Some 20 people, including several women, had been inside the small, 12-by-50-foot club space, gambling at a poker table and playing the dice game cee-lo, at a second table when the guns came out, sources said.

That’s when Goode pulled a 9mm and began firing into the ceiling, ordering everyone in the room to get down on the floor, according to the sources.

Investigators Saturday night were still trying to piece together who shot whom, based on video surveillance, ballistics and witness accounts, but they believed that only the two recovered guns had been involved and that there were no suspects at large, the sources said.

The four fatalities were pronounced dead at the scene; the three who were shot but survived were rushed to hospitals, officials said. An eighth victim needed treatment for a broken leg sustained in fleeing the venue.

The floor was left covered with bodies, blood and playing cards. Above one fallen player, more cards still rested on the poker table, face up, including a Queen and King that that would have been a good hand if dealt to a single player.

Worried relatives rushed to the scene as word of the shooting spread in the neighborhood.

“He won’t pick up the phone!” a worried woman shouted into a cellphone alternately screaming and sobbing.

“He won’t answer! Oh God!”

In another overheard cellphone call, a man said he’d narrowly escaped the flying bullets by running out a back exit.

“When the shots started popping off, people bolted — they scattered like cockroaches,” he said.

The gambling operation was unlicensed, Chief of Detectives Dermot Shea said.

But Revells, who owns the building, said he knew nothing of the club’s after-hours operations, and only rented it out to family functions.

“I thought they were having birthday parties, things for funerals in there,” he said. “In the two years since I leased it we haven’t had any problems, no police.”

Revells said he’d been on his way to the building when he heard about the bloody affair.

“I was on my way over to fix something and I have tenants calling me telling me what happened,” he said. “It’s all over money,” he said sadly.

The club, which bills itself as a “private and social rental space,” does not appear to hold a liquor license or a business license, online records show.

Shea said it did not appear that alcohol was being consumed on the premises.

The venue’s operation seems to date back at least a decade — the location received two complaints in November 2008 reporting that the first floor had been converted into a nightclub, according to Department of Buildings records.

One caller said the space was being used as a “men’s club,” the complaint shows.

“It seems like this place has been around for a while, operating under the radar,” Community Advocate Tony Herbert of the New York Multi-Cultural Restaurant & Nightlife Chamber of Commerce told The Post.

“There are a host of these kinds of venues that are operating in NYC. Some are law-abiding, others don’t have the proper permits and operate under the radar praying that incidents like this [don’t] happen,” he said in a statement.

The Brooklyn shooting comes seven days after four homeless men in Manhattan were fatally bashed as they slept on the street.

“I pass the place every day and I see people hanging out outside,” said neighbor Jose Torres, 24.

He saw two violent groups of people going at it — shouting at and shoving each — just two weeks ago, he said.

Torres had heard the shots Saturday, and had reassured his mother that it was nothing.

“After midnight this neighborhood changes,” he said.

After the deadly shooting, Borough President Eric Adams called for increased funding for areas like Crown Heights and nearby Brownsville, where 12 people were shot at a block party in July.

Hizzoner also weighed in, decrying the “epidemic” of gun violence in the area.

“I’ve said it before and I’ll say it until I can’t anymore: we have an epidemic of gun violence that spares no community — and it won’t stop until we get guns off our streets once and for all,” Mayor Bill De Blasio tweeted.

Additional reporting by Tina Moore, Kevin Fasick and Laura Italiano