If the targeted land is an illegal target by the time Roiling Terrain resolves, the entire spell doesn’t resolve. No damage will be dealt.

Artwork
Loading artwork…
Roiling Terrain
Worldwake · #88 · EN
Nonfoil—Foil—
Card rules
Destroy target land, then Roiling Terrain deals damage to that land's controller equal to the number of land cards in that player's graveyard.
"The trembling lands ruptured, leaving an open door for things from below to emerge." —Screed of the Mul Daya
Common · Illustrated by Steve Prescott
Format legality
Commander Legal
Duel Legal
Legacy Legal
Modern Legal
Oathbreaker Legal
Pauper Legal
Pauper Commander Legal
Penny Legal
PreDH Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Old School Not Legal
Pioneer Not Legal
Premodern Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
The effects of the spell happen in sequence. By the time Roiling Terrain checks how many land cards are in the affected player’s graveyard, the land Roiling Terrain destroyed is (most likely) already in that graveyard.
If the targeted land regenerates or has indestructible, Roiling Terrain still deals damage to the targeted land’s controller.