Credit: NPG; Jean Baptiste Lacroix/WireImage.com

He can't win them all.

Charlie Sheen lost his bid for sole custody of his and estranged wife Brooke Mueller's twins on Tuesday afternoon. The embattled actor, 45, was denied a change in the current custodial agreement by L.A. County Superior Court Judge Hank Goldberg, TMZ reports.

Like Sheen, Mueller, 32, has battled drug addiction. She checked into a sober living facility voluntarily in December; an insider told Us Weekly at the time she was "starting to feel tempted."

After allegedly threatening to kill Mueller and demonstrating erratic behavior, Sheen's sons were removed from his home-- which he called "Sober Valley Lodge"-- in March. But with the recent development of Mueller checking into rehab yet again and dropping her restraining order against Sheen, the odds looked favorable for the Two and a Half Men star.

But Judge Goldberg decided that Mueller's mother, Moira Fiore, should continue to take care of Bob and Max while their mother seeks treatment; Sheen will be granted visitation rights as long as he continues to pass court mandated drug tests.