Lindsay Lohan will play herself in upcoming film

The 26-year-old actress - who was sentenced to 90 days in rehab, 30 days of community service and 18 months of psychotherapy last week after pleading "no contest" to charges for lying to police about a car crash last June - will poke fun at her legal troubles while she playing herself in an upcoming guest starring role on 'Anger Management', filming for which will wrap up in Los Angeles on Tuesday as her onscreen character goes to jail to perform community service.

The troubled starlet - who is set to fly to Brazil on Wednesday to promote a clothing line before being admitted to a treatment facility in the US - has been a dream on set, according to gossip website, as she has been extremely nice to everyone and nailed all of her lines.

An insider said: "Lindsay knew her lines cold and her timing was perfect. She was really funny. (She) proved she has talent. You watch her and you know why she became a star."

The actress also posed for pictures with other cast members, including Darius McCrary, who were dressed in orange jumpsuits to play inmates after completing her first day of filming on Monday.

The role also sees Lindsay's character sleep with the show's star Charlie Sheen.

The duo became firm friends after filming a cameo for 'Scary Movie 5' last year and Charlie, who has repeatedly supported the actress, even gave her $100,000 to pay a tax bill.