After returning from a shop that sells returned wedding cakes, Maggie gets locked in the car with the key inside. While searching for the spare keys (which soon proves unnecessary, as Maggie is able to free herself), the Simpsons discover a collection of keys to every door in Springfield. Lisa uses a key and finds a hidden classroom full of theater props underneath the school. She is intrigued by the discovery, and shares it with Principal Skinner, but when she brings along the school newspaper, they only find what is supposed to be behind the door, the "Banned Band Books". It becomes apparent that Skinner and Superintendent Chalmers are hiding something when they snatch the key from Lisa. She has the key replicated and returns to the door on her own, and finds the classroom is back; it had been hidden behind a phony set of bookshelves. She also sees a mysterious figure writing "The children are on Bus 23" on the chalkboard. Lisa is determined to solve the mystery of the hidden room.
Meanwhile, Bart tries causing mayhem with the keys but accidentally does good deeds with them, and ends up with the key to the city. Marge and Maggie find a key for a wind-up toy train called "The Pooter Toot Express", which makes farting noises when it moves. The toy gets away from them and they chase it throughout the city. Homer uses a key to get into the Duff Beer brewery with Barney and goes joyriding in the Duff Blimp.
To get more information about Bus 23, Lisa and Bart ask Nelson. Nelson explains Bus 23 was a bus full of children that was supposed to drive over a dangerous ice bridge but was never heard from again, as Skinner and Superintendent Chalmers covered up the loss of the children. Lisa tells Bart about the room, and the two ask Homer to fly them to the lake where the ice bridge would be. Lisa falls out of the blimp and into the water, where she sees the submerged Bus 23, and Homer dives in to save her. However, they find that all the "children" inside it are actually mannequins. Homer and Lisa are saved by the Pooter Toot Express, which knocks over a tree for them to grab onto just before it falls apart. The mysterious figure is revealed to be Otto, who is relieved to discover he is not responsible for the death of the children, as he was the driver of Bus 23.
Chalmers and Skinner try to flee to Bolivia, but are stopped by Bart, who has Skinner's car key and forces them to explain everything. Years earlier, the school had received a large grant for the purpose of improving its classrooms. Skinner cashed the check but left the money in his pants pocket, and his mother inadvertently destroyed it when she washed his laundry. With the help of Groundskeeper Willie, Chalmers and Skinner built a fake classroom and photographed it to fool the government, using rented mannequins to pose as students. They put the mannequins on Bus 23 to have Otto return them before having to be charged for the extra day, but the ice bridge gave out and the bus went into the lake. Chalmers and Skinner apologize to Otto for letting him believe he killed a busload of students, and all is forgiven. No further mention of the rental money is made, though Skinner says that they anticipated the wedding cakes but not Maggie locking herself in the car, and Chalmers chastises him for not anticipating her birth.
The epilogue ends with Otto driving his bus across an icy bridge, believing that his complement is full of mannequins, when he is actually transporting real children. As his bus is close to tipping off the bridge, he comments that perhaps they will fall off slowly as in Inception; he is wrong and his bus falls into the river. The episode ends with the sound of Otto searching for his keys to let the children off the bus to swim to shore.