Teamwork makes the dream work, and they proved it in Panama City over the weekend.

Cellphone footage captured from a PC balcony shows dozens of beachgoers forming a human chain — with up to 100 people locking arms at one point — as they attempted to save two swimmers caught in rip currents caused by Tropical Storm Barry, a report says.

Witnesses told CBS Miami that the swimmers had been out in the water illegally on Sunday, with double red flags reportedly flying at the time.

“I immediately ran over to see what was going on and there was two people that had actually went so far out past the waves … they couldn’t get back,” recalled Shelly Callaway, who was working at the nearby Treasure Island resort condo.

“The current was so rough that they could not literally swim back in.”

Callaway said “there must have been 50 to 100 people holding hands, lined up from the beachside out to the waves so they could help the rescuers and help the people come to shore.”

At least two beachgoers “actually got stuck in the current” and had to be rescued themselves, she added.

It’s illegal to swim when there’s a double red flag, and authorities stressed this Tuesday.

“You can actually be given a criminal citation or even placed under arrest and taken to jail,” said Sgt. Mike Morris of the Bay County Sheriff’s Office Surf Rescue. “We want to avoid that and just have people stay out of the water for their own safety.”

At least 90 people have been pulled from the Gulf since Friday, according to police officials.

Tropical Storm Barry was bearing down on the region throughout the weekend, sparking the rough conditions.

“I just think that everybody should take the double red flags seriously,” Callaway said. “When you see the double red flags you need to stay out of the water.”