While visiting a cave at Carl's Dad's Caverns, Homer meddles with a very fragile stalactite, with the result that the whole family ends up in a hidden cavern below the main tour—with Homer stuck in a narrow hole, half in and half out of the cavern. To pass the time while Marge and Bart try to find a way out, Lisa begins to tell a story.
Lisa tells how, the week before, she had been out for a walk when a bighorn sheep inexplicably attacked her. She ran to the nearest shelter, Mr. Burns' house. The animal bursts in, and she and Mr. Burns wind up hiding in the attic. There, Lisa finds a photo of Mr. Burns as an employee at Moe's, and he tells her the origins of it.
Mr. Burns explains that once, he and Rich Texan were involved in a scavenger hunt, the winner of which would get all the possessions of the loser. Mr. Burns was unable to find the last item on the list—a picture of himself with a smiling child. (Every child was terrified of him and Milhouse says he is the "boogeyman's grandfather".) The Texan won, and Mr. Burns explains that he had to earn his fortune all over again by starting at the bottom; but to work his way up to the bottom, he would have to work at Moe's Tavern. While there, he found a hidden letter to be read upon Moe's death, which led to Moe's story of a hidden treasure.
Apparently, the summer before Mrs. Krabappel was to begin teaching, she and Moe met and fell in love, albeit without her knowing he owned a bar (she hates bar owners). Moe tosses Homer, Barney, Lenny and Carl out of his tavern before closing it, and when they confront him about it later he tells them he will out the one of them who is gay (unidentified) if they ruin things for him and Edna. Moe then wanted to leave Springfield with her but had no money. He then discovered that Snake (before he became a jailbird, Snake used to be a polite idealistic archaeologist) had discovered a large batch of Mayan coins he was going to donate to the museum. Moe ended up stealing them, embittering Snake and leading him to take revenge against convenience store owners. He was then about to leave town with Edna, but when she went into the school to explain that she was quitting, she saw Bart. (This leads to her story.) Bart explained he had all-summer detention, and felt he was a lost cause because no one believed in him. Edna declared that the next year, when she was to teach fourth grade, she would help him to succeed, and explained this to Moe, who reacts crazily. It turns out, however, that Bart was actually just distracting Edna while he and Nelson were stealing microscopes and other classroom equipment.
Rather than spending the stolen coins, Moe uses them to play his and Edna's song on his jukebox repeatedly. Mr. Burns (here ends Moe's story) opened the jukebox, took the coins and gave them to the Texan to buy back his possessions, but the Texan demanded that Mr. Burns produce a picture of himself with a smiling child before he could get the Plant back. (The Texan, he explained, has obsessive-compulsive disorder, thus feeling the need to complete the scavenger hunt.) End of Mr. Burns' story — he explains to Lisa that he cannot get the plant back.
Just then, the goat burst into the attic. Mr. Burns got hurt defending Lisa; however, it turns out that it doesn't want to kill them—in its story (which lasts but a few seconds) it explains that it found Lisa's pearl necklace and was merely trying to return it. Lisa, in gratitude to Mr. Burns for his attempted rescue, takes a photo of the two together with her smiling. This exits to the cave scene.
Just then, Homer breaks free of his trap, and suddenly reveals that he had an ulterior motive for bringing the family to the caves. He tells a story, explaining that while in the woods (hiding from babysitting duty), he saw the Texan hide the gold coins in the cave, and brought the family so they could search for the gold to pay for an operation for Bart (the need for which was unknown to the rest of the family, including Bart, who is now shocked by this... but Homer says that story will have to wait to be heard). Just then, the Texan shows up, and the gold is found — just in time for Moe, Mr. Burns and Snake (who also brought his little son) to also appear, and they enter a Mexican standoff. Marge grabs the bag and threatens to drop it down a deep pit if they do not end their standoff. When she discovers the depth of their greed, she drops it—and instantly, everyone realizes how greedy they had been, and go out to volunteer as a way of atoning for their sins, except Mr. Burns, who attempts to climb down to get the gold.
Suddenly, it is revealed that the whole episode has all been a story by Bart (potentially explaining apparent continuity errors), being told to Seymour Skinner as an explanation for why he did not have time to study for a test. The principal finds this ridiculous—until he sees Moe and Edna kissing outside the school. To his disgust, he realizes that Bart was telling the truth. When Moe asks to Edna why she forgives him for lying to her, she confesses that all she really wants by now is a man with a healthy libido. Unfortunately, it appears Moe cannot even fulfill this very simple requirement, and the Rich Texan obsessively shoots his guns and notes "Moe can't catch a break!"