While visiting a cave, Homer meddles with a very fragile stalactite, causing the family to fall deep into the caves. Homer is stuck hanging upside down from a narrow hole, and while Marge and Bart try to find a way out, Lisa tells him a story to pass the time.
In Lisa's story, a bighorn sheep begins to attack her. She runs to the nearest shelter, Mr. Burns' house, and they hide in the attic. There, Lisa finds a photo of Burns as an employee at Moe's Tavern, and he tells her the origins of it. Burns explains that he and Rich Texan were once involved in a scavenger hunt, with the winner getting all the possessions of the loser. Burns was able to get every item besides one: a picture of himself with a smiling child. The Texan won, and Burns had to get a job at Moe's to regain his fortune. While working, he finds a letter by Moe about his secret treasure.
The summer before Edna Krabappel was to begin teaching, she and Moe met and fell in love. Moe wanted to leave Springfield with her but had no money, only for Snake, a polite idealistic archaeologist, to bring a large amount of gold coins he intended to donate to a museum. Moe stole them from Snake, leading him to begin a life of crime. Before Moe and Edna are about to leave, Edna stops by Springfield Elementary School and finds Bart with detention over the summer, claiming he does bad in school because nobody believes in him. Edna tells Moe that she will stay in Springfield to help Bart succeed. Back in the cave, Bart explains that he was lying to distract Edna and help Nelson steal classroom equipment.
Moe became depressed and used his coins to play music he and Edna liked on the tavern's jukebox repeatedly. After reading the letter, Burns took the coins from the jukebox and bought his possessions back from the Texan; he complies, but refuses to give the nuclear power plant back until Burns completes the scavenger hunt. The sheep bursts into the attic, and Burns gets hurt defending Lisa. The sheep shows that it found Lisa's pearl necklace and was merely trying to return it. Lisa, in gratitude, takes a photo of her and Burns together, allowing him to get the plant back from the Texan.
After Lisa's story, Homer breaks free from the hole. He reveals that he saw the Texan hide the gold coins in the cave, and brought the family there to steal them. Just then, the Texan shows up, and the gold is found. Moe, Burns, and Snake appear, and enter a Mexican standoff. When Marge grabs the bag of coins and drops it into a chasm, everyone realizes how greedy they had been and thank her for getting rid of the gold, except for Burns, who attempts to climb down the chasm to retrieve the gold.
The episode is revealed to have been a story by Bart, talking to Principal Skinner as to why he was unable to study for a test. Skinner is unconvinced until he sees Edna making out with Moe outside the school. When Moe asks Edna why she forgives him, she says that she "just wants a man with a healthy libido." Moe is unable to fulfill this request, and the Texan cheers, "Moe can't catch a break!"