A young girl named Vanellope von Schweetz steals Ralph's medal to buy her way into the nightly race that determines which characters are playable the next day, but King Candy, the ruler of Sugar Rush, forbids her from racing because she has glitches that cause her to teleport erratically. Ralph reluctantly agrees to work with Vanellope to retrieve his medal and help her win a race. They build a kart and hide out at Diet Cola Mountain, an unfinished race track, where Ralph teaches her to drive. King Candy hacks the game's code to obtain Ralph's medal, and offers it to Ralph in exchange for preventing Vanellope from racing. He explains that if Vanellope wins she will become playable and her glitches will lead to Sugar Rush being unplugged. Unable to leave the game because of her glitch, Vanellope will be left to disappear while King Candy and his subjects become homeless in the arcade. Ralph reluctantly agrees and destroys Vanellope's kart. Heartbroken, she declares he "really is a bad guy" and runs off distraught. Upon returning to his game, which has been evacuated in anticipation of it being unplugged the next morning, Ralph notices Vanellope's image on the side of the Sugar Rush cabinet and realizes she was meant to be a playable character. He returns to Sugar Rush and learns that King Candy had disconnected her code to render her a glitch, and erased all of the other characters' memories of her, resulting in her becoming a hated outcast.