Tyga’s house in a gated community got rolled by a crook who plotted an escape straight out of a Hollywood script … and actually got away — only problem is Tyga doesn’t live in the house anymore.

It all went down in the same Calabasas ‘hood where Kourtney Kardashian, Khloe Kardashian, and Katie Holmes live. Law enforcement sources tell TMZ … the burglar asked someone on the block which house was Tyga’s … and then slipped into the backyard.

What he didn’t know was … Tyga had sold the crib to music exec Anthony Tiffith. Sources connected to the Tiffith fam tell us the suspect managed to bust in through a back window while Tiffith was in a different part of the house.

Now to the great escape. We’re told the burglar fled the house, and immediately called 911 and said he had mental issues and needed to be taken away. Paramedics responded and took him to a hospital for evaluation.

Meanwhile, back at the house … Tiffith realized there’d been a break-in, reviewed his surveillance camera footage, and then called neighborhood security … who called cops.

Short story … by the time cops connected the dots and went to the hospital — the burglar had bolted from the hospital. Police are still searching for the suspect.

One more weird note … after all that, we’re told the guy only made off with 2 cell phones. Hardly an Ocean’s 11 heist, but effective.

tagged in Calabasas, Tyga