Riley's mind is made up of five emotions- Joy (Amy Poehler), Sadness (Phyllis Smith), Anger (Lewis Black), Disgust (Mindy Kaling) and Fear (Bill Hader). They create Core Memories for her inside her "Command Center" that define who she is.
When Riley and her family move to San Francisco, the Core Memories are ejected out into Riley's mind, along with Joy and Sadness. As a result, Riley starts to slowly lose her personality.
Anger tries to make Riley happy by planting an idea in her mind that she wants to run away back to her old home. Riley steals money from her mother and gets on a bus, just as Joy and Sadness make it back to the Command Center and remove the idea. Riley gets off the bus just in time.
Riley makes it back to her parents and Sadness takes over Riley as she cries that she wants to go home. Her parents tell her that it's okay to be sad and they hug her, earning a smile from Riley. A new Core Memory is created- a combination of Joy and Sadness. Riley's personality is restored as a result.