Here is the transcript for A Ghostly Problem.
At the Castle of Friendship in Equestria, SpongeBob SquarePants was having a fun time with his friends.
SpongeBob SquarePants: (laughing) And... And... And there was that time we scared the barnacles out of everyone in Bikini Bottom, We were called "The Bikini Bottom Ghosts" Just before they and Mr. Krabs got back at us in the nude!
Rainbow Dash and Pinkie were laughing.
Pinkie Pie: You are too funny, SpongeBob!
Rainbow Dash: Oh yeah, I'd bet that was so embarrassing.
Patrick Star: Yep, But we could've gotten something else.
Twilight Sparkle: Like what, Patrick?
SpongeBob and Patrick looked at each other, Then back to Twilight.
SpongeBob and Patrick: A Whoopee Cushion.
And they all laughed at each other.
Pinkie Pie: You two must've done a craziest prank yet!
SpongeBob SquarePants: Well, I was gonna use the Invisible Spray on the bench.
Patrick Star: And the reason why I got naked is because it stains cloths.
Applejack: Patrick Star, As my honest opinion, That has got to be by far the most dumbest idea you ever did.
Rarity: And obviously the worst.
Rainbow Dash: But at least you guys learned not to do that anymore.
Pinkie Pie: It was just dumborst anyway.
Fluttershy: By which Pinkie means Dumb and Worst into one word.
Applejack: But not even a real word.
Spike: Well, I still think it was funny.
Sunset Shimmer: (giggled) Me too.
Starlight Glimmer: My favorite is how you two pulled that Bikini Bottom Ghost Prank.
SpongeBob SquarePants: I'm glad you think so, Starlight.
That night, SpongeBob was just spending the night with his Equestrian friends as he goes to find a midnight snack.
SpongeBob SquarePants: Just one quick midnight snack and I'll be back in bed.
Then, He hear a strange noise.
SpongeBob SquarePants: (gasps) What was that?!
Just as he looked around, There was Spike with Starlight and Sunset.
SpongeBob SquarePants: (screamed)
Spike, Starlight and Sunset: (screaming)
SpongeBob SquarePants: Oh, Spike, Starlight, Sunset. It's just you three. I thought I've heard a ghost.
Spike: That's okay, SpongeBob.
Starlight Glimmer: We were just checking on you.
Sunset Shimmer: Are you okay? You look like you haven't been yourself since yesterday.
SpongeBob SquarePants: Really? I've felt like I'm hearing things.
Starlight Glimmer: Okay, You seemed a little tensed. We'll give you some space.
The next morning, Twilight was checking her "To Do" list for her agenda.
Twilight Sparkle: Okay, What's the first thing on the agenda?
Spike: (shows Twilight the list) Here you are, Twilight.
Twilight Sparkle: Oh yes, Come to witness the Canterlot Royal Banquet.
Just then, SpongeBob's scream was so loud that Twilight heard him.
Twilight Sparkle: SpongeBob?
Soon, She had to go check on SpongeBob.
Twilight Sparkle: SpongeBob, What's going on?
SpongeBob SquarePants: I've just kept hearing things, I just thought I've seen a ghost.
Twilight Sparkle: Oh, SpongeBob. There's no such thing a ghosts. You're just getting in your head.
SpongeBob SquarePants: But what if it is, Twilight. It could haunt anywhere soon.
Spike: Hmm, I don't get what's up with SpongeBob.
Twilight Sparkle: Me either, Spike. I'm getting a little worried.
Later that night in Bikini Bottom, SpongeBob had trouble sleeping.
SpongeBob SquarePants: Oh, Gary. I can't sleep, After all tha ghost shenanigans.
Gary the Snail: (meows asking if he could help)
SpongeBob SquarePants: No thanks, Gary. I'm sure somebody could just magically appear at night to come and help me with my ghostly problem.
Just then, A glowing light started to appear in front of him.
SpongeBob SquarePants: (gasped) What the Barnacle is Happening!?
From that light, Out come Princess Luna, SpongeBob was awkwardly surprised.
SpongeBob SquarePants: Sweet Mother of Neptune, Princess Luna! (grovels as she bows) Your Majesty, I worship your appearance! (kisses her fore hooves)
Princess Luna: There is no need for your loyalties, SpongeBob.
SpongeBob SquarePants: Sorry, I get emotional with royalties.
Princess Luna: Now then, I'm going to ask you to come with me.
SpongeBob SquarePants: Why? Where are we going?
Princess Luna: To visit your past and to overcome your fear.
So, Luna took SpongeBob to the past.
Soon, They've reached SpongeBob's childhood.
SpongeBob SquarePants: Where are we?
Princess Luna: You will see when we get there.
Just as they arrived, SpongeBob Couldn't believe his eyes.
Princess Luna: Notice anything familiar to you, SpongeBob?
SpongeBob SquarePants: (gasps) That's me! I was in kindergarten back then during camp.
Princess Luna: That's correct, You enjoyed camping back then.
Camp Councilor: Okay, Kids. Do we have a volunteer who will tell us a Ghost Story?
Then, One of the kids volunteered and told them the ghost story.
SpongeBob SquarePants: (starting to remember) I think I remember, This is where I was scared of scary stories.
Princess Luna: Can you remember anything else?
SpongeBob SquarePants: Well, Mr. Krabs told me a scary story about the Flying Dutchman.
Princess Luna: We all have fears, SpongeBob. Even I do.
SpongeBob SquarePants: Really, Princess Luna? Since when?
Princess Luna: Well, I'll show it to you. I was afraid of ghosts ever since I was a baby.
SpongeBob SquarePants: No kidding.
Princess Luna: It's true.
Then, Luna took SpongeBob to her fillyhood.
They reached Luna's fillyhood, SpongeBob was puzzled.
Baby Luna: (sleeping)
SpongeBob SquarePants: Is that you?
Princess Luna: Yes, SpongeBob. This is when I was a baby filly.
Suddenly, Baby Luna woke up crying.
Baby Luna: (crying)
Teen Celestia: Huh? What's the matter, Baby sister? Are you having a nightmare again?
Baby Luna: (calms down and hugged her big sister)
Teen Celestia: Aww.
SpongeBob SquarePants: (laughed) You were such a cute baby, Princess Luna.
Princess Luna: Of course, It was a long time ago. You see, SpongeBob. Everyone has fears, Even in their dreams. But you can't just let anything from the past get the best of you. Sometimes, It takes a small amount of courage to overcome fear. Do you understand?
SpongeBob SquarePants: I understand, Princess Luna.
Princess Luna: Now, You know how I felt during my infancy.
Teen Celestia: (kisses her baby sister's cheek) Sweet dreams, Baby sister.
Baby Luna: (sleeping heavenly)
Soon, She returned him back to his own dream.
Princess Luna: So you see, SpongeBob. As long as you dream heavenly, You can do anything.
SpongeBob SquarePants: You're right, Princess Luna. Thanks for everything, Goodnight.
And Princess Luna returns to Canterlot as SpongeBob sleeps peacefully.
The very next morning in the Castle of Friendship.
SpongeBob SquarePants: Hi, Twilight. How's everything today?
Twilight Sparkle: Are you feeling alright, SpongeBob? You're acting different somehow.
SpongeBob SquarePants: Yep, I'm doing much better after a goodnight's rest.
Twilight Sparkle: That's good, SpongeBob. My friends and I could use some help studying. Would you like to join us?
SpongeBob SquarePants: Sure, Twilight. I'd be delighted.
And her happily joined Twilight and her friends with their studies.