A Los Angeles judge ruled on Tuesday that Charlie Sheen's twin boys Max and Bob will be staying in the care of his ex-wife Denise Richards while their mother, Brooke Mueller, undergoes treatment for her prescription drug addiction.

The two four-year-olds were taken from Mueller's home on Thursday by the Department of Children and Family Services, officials for which called her home an "unsafe environment" for the children.

Richards, who took custody of the kids so they could be with their half-sisters Sam and Lola, accompanied Sheen and Mueller's lawyers to court on Tuesday, where a judge granted Richards temporary custody, according to TMZ.com.

Mueller Checked into the UCLA Medical Center last week to begin treatment for her addiction and is expected to move to a rehabilitation facility.

It's not the first time Richards has cared for the twin boys, she looked after the boys in 2011 -- while Mueller was again in rehab.

Sheen released a statement through his representative on Friday, who said, "Charlie supports the actions of the Department of Children and Family Services. He knows Max and Bob are safe and in a stable, loving environment with Denise and the boys' sisters."