Carol Edwards (played by Melissa McCarthy) and Phil Phillips (voiced by Bill Barretta) in The Happytime Murders (STX Entertainment)

Years after Avenue Q and Peter Jackson in his 1989 cult film Meet the Feebles featured puppets based on the Muppets cursing and engaging in bad behavior, another filmmaker throws down his hand with The Happytime Murders, and it’s a solid straight flush, if not a full house.

In an alternative Los Angeles where puppets and humans interact, puppets are treated as second-class citizens, and someone is killing off the cast of the first integrated puppet/human show, Happytime. It’s up to disgraced ex-cop and current private eye puppet Phil Phillips (voiced by Bill Barretta) and his former partner Connie Edwards (Melissa McCarthy) to solve the murders. The plot itself is a clever pastiche of Who Framed Roger Rabbit, Lethal Weapon, and Basic Instinct with a dash of neo-noir thrown in. Of course, most viewers aren’t here for the plot. They are here for R-rated Muppet-like action. And boy, do they get it.

It takes about 20 minutes for the antics to rev up. At first, as director Brian Henson (son of Muppets creator Jim Henson) and company set up the tropes of the story’s universe, the movie seems a little tame. But then Phil enters a puppet porn shop and the dial gets turned to 11. You will see things being done to a puppet cow that you never want to see. From then on, the rubber hits the road, and there’s no looking back. There are puppet addicts (addicted to sugar), felt fatales, man on puppet sex, puppet on puppet sex, puppets heads getting blown off, and something called pilafing, which is worse than it sounds.

All of this would be ludicrously juvenile—well, it is ludicrously juvenile—except for one mitigating factor. The Muppets have always been excellent genre parodists. From Sesame Street to The Muppet Show, these characters know how to affectionately riff on genres, and here their counterparts are no different. They understand the buddy cop dynamic, and McCarthy and Barretta play off each other beautifully.

Phillips’s narration is completely on-point. His need for redemption echoes countless noir films from the ’40s. His latest client, the sultry felt femme fatale Sandra (voiced by Dorien Davies), is a perfect mix of Veronica Lake and Sharon Stone. Maya Rudolph almost walks away with the whole movie as Phillips’s lovestruck and loyal secretary Bubbles (of course.)

The mystery isn’t too bad, either. None of the Happytime cast is at their best 20 years after the show ended, and Henson and scriptwriter Todd Berger use the cast members’ sob stories to enter various seedy environments. Mayhem and puppet death follow. The perpetrator comes out of left field, yet the identity completely makes sense.

Of course, the movie wouldn’t hold together without a solid, charismatic lead, and Barretta is just that man. If a puppet could have charisma, it’d be this one. Barretta invests Phillips with a cynicism worthy of Humphrey Bogart and the soft spot of every Raymond Chandler detective. His voice is simultaneously inviting and harsh, and his physical performance of the puppet itself is top-notch. Barretta manages to be both subtle and funny.

There are flaws, though.  The jokes don’t always land, and for some reason, there is a running gag about Edwards looking like a man because she dresses in pantsuits. (I guess.) McCarthy is game, but it’s a little tonally odd joke, but because McCarthy is game, it still elicits a chuckle or two.

Overall, The Happytime Murders is good, dirty fun. One quality of the Muppets is that they always walk to the edge of anarchy. Even on Sesame Street, there’s the danger of total mayhem. Here the puppets hop over the edge, and the results are funny and satisfying.

Directed by Brian Henson
Written by Todd Berger
Released by STX Entertainment
USA. 91 min. Rated R
With Melissa McCarthy, Elizabeth Banks, Maya Rudolph, Leslie David Baker, and Joel McHale