It’s been three decades since Bobcat Goldthwait rose to the top of the stand-up comedy scene, thanks in part to the trademark vocal squeaks, garbled pronunciations, and decidedly dark humor that distinguished him from his peers, and eventually helped him land roles in movies like One Crazy Summer and the Police Academy series.

Over the years, however, the 53-year-old performer has moved behind the camera, directing Robin Williams in the warmly received 2009 indie World’s Greatest Dad, among other titles. But the late comedian — who died last year at the age of 63 — wasn’t simply a colleague. “Robin Williams was my best friend,” Goldthwait told Yahoo Movies in a phone interview on Tuesday.

As it turns out, Williams also served as an inspiration for Goldthwait’s latest film, the documentary Call Me Lucky (you can watch the exclusive trailer above). The film follows influential comedian and activist Barry Crimmins, and it wouldn’t have been made without Williams’s help. Goldthwait always planned to tell Crimmins’s story as a biopic, but struggled with that approach. “Robin was a fan of Barry’s, and he knew what I was trying to do,” recalled Goldthwait. “He suggested to make it a doc.” Williams then gave Goldthwait enough money in the spring of 2014 to start filming.

The resulting doc, which opens in select cities Aug. 7 before expanding nationwide, has been a hit on the festival circuit, despite its heavy subject matter. Crimmins, whom Goldthwait first met in the 1980s, made his mark as a larger-than-life comic — a firebrand who was highly critical of the Reagan administration, and who also happened to be a heavy drinker prone to fits of anger. Goldthwait met Crimmins on the Boston comedy circuit, and was immediately fascinated with him. Crimmins soon became Goldthwait’s mentor — and, at times, an unlikely protector. “[At one point], Barry had his fist in a cast because he had punched a wall,” Goldthwait said of their time together. “I had just stopped drinking, and one of the other comedians was trying to pour liquor down my mouth… [Crimmins] ended up breaking [the] guy’s jaw, possibly.” He added with a laugh: “Well, actually he did [break it] — I’m trying to change the story a little bit for legal reasons.”

Goldthwait was first inspired to make a movie about Crimmins 20 years ago, after he watched the comic testify against AOL on the U.S. Senate floor, where he spoke out against un-policed, rampant child-porn chat rooms (Crimmins himself had been a victim of sexual abuse as a child). Crimmins’s testimony is a pivotal moment in the film, which follows him as he resided over Boston’s burgeoning comedy scene in the ‘80s, where he mentored not only Goldthwait, but also such young acts as Paula Poundstone, Steven Wright, and Denis Leary.

Call Me Lucky includes footage of the comic in the earlier years, as well as several interviews with Crimmins himself. In this sense, Call Me Lucky an authorized biography, “but he gave me all the freedom I wanted,“ Goldthwait said. ”[Crimmins] never saw the movie until he sat there at Sundance with me — which is pretty crazy, because the movie ended up premiering at the same theater at Sundance as World’s Greatest Dad did. It was the same kind of thing, because I didn’t show Robin any of that movie, either. Fortunately, they both liked it. [But] it could have been terrible.”

Ultimately, Goldthwait said, “this movie is bigger than me. It’s about Barry’s courage, and it’s also addressing a problem that’s much larger than I had any idea when I made the movie.” Abuse survivors have approached the director after each of his many festival screenings. “It’s very powerful,” said Goldthwait, noting with a laugh: “And it’s really f—ing up me being a misanthrope, because now I’m being forced to hug people.”