Getting unpredictable Lindsay Lohan to do a cameo role in “Scary Movie 5” has been a frightening experience for producers as she tried to avoid a scene making fun of her troubles.

Dimension Films signed Lohan to play a cameo in the horror spoof opposite Charlie Sheen. But over the past two weeks — as the date for filming approached — Lohan disappeared, blew off rehearsals, missed her flight to the set and even bizarrely claimed she had walking pneumonia.

We’re told the troubled starlet “freaked out” after seeing the script was poking fun at her. At the 11th hour, Lohan did report for work, however only after she was threatened with a lawsuit by a Hollywood legal eagle and a private jet was sent to pick her up, sources tell Page Six.

PHOTOS: LINDSAY LOHAN

“Lindsay missed every meeting she had for the film, including script reads and wardrobe meetings,” said a Hollywood insider. “Then she missed her flight to Atlanta on Sunday to shoot the movie. The producers had been getting signs Friday that she was a mess, and would not be fit to work.”

Multiple sources say that Lohan decided she didn’t want to do the film because she thought her scene made too much fun of her. “It went pretty hard at Lindsay,” said a source, adding the script features a kiss with Sheen, and that “she’d been freaking out about it for weeks.”

But when a call was scheduled to discuss the script, Lohan missed that, too, sources say.

Yet another source tells us that Lohan last weekend began saying she couldn’t do the film because she had “walking pneumonia,” and went to a hospital Sunday to get her lungs checked.

“She is under contract — so to get out of it, she had to prove that she was sick,” said a source. “She tried to prove she has walking pneumonia.”

Another summed up, “She’s been locked up in her room at the Bowery Hotel. She’s been in a tailspin. Even Charlie Sheen worried she might not be able to do the scene.”

A rep for Lohan said, “These stories are untrue, and she is willingly fulfilling all of her obligations.” Reps for Dimension had no comment.