Ash and Goh arrive at the Mossdeep Space Center in Hoenn, where they're immediately greeted by Ash's former classmate from Alola, Sophocles. Sophocles is accompanied by an Ampharos, who stumbles out of clumsiness when trying to greet Ash and accidentally hits him in the face. Goh introduces Sophocles to his Grookey and Cinderace, the latter of which was still a Raboot back when they last met. Sophocles, in turn, tells that the others are doing fine in Alola, with Kiawe even being eager for another battle with Goh, before giving him and Ash a tour around the Space Center.
Eventually, Sophocles brings Ash and Goh to the mission control, where he introduces them to Ellery, one of the researchers working here. The current project they're working on is the return of Talonflame 2, a space probe once launched from the Mossdeep Space Center to retrieve a sample from an asteroid. After successfully completing what it was set out to do, it is now returning to the planet, which is where Ampharos comes in. Four observatories around the world will be amplifying the light produced by Ampharos and firing it into space, with Talonflame 2's light sensor using the beams as beacons to navigate its way back home. Ellery asks Sophocles and Ampharos to get into position, but while rushing after Sophocles, Ampharos ends up hitting both Ash and Goh with its tail. Dejected over this, it walks over to Sophocles in low spirits and almost steps on Togedemaru, who jumps back to dodge and accidentally hits a machine.
Ampharos takes its place in a special chamber as the Mossdeep Space Center prepares to take over from another observatory in guiding Talonflame 2. Sophocles tells Ampharos to illuminate its lights, which are fired into space seconds later, successfully reaching Talonflame 2's light sensor. However, only moments later, the machine Togedemaru hit earlier malfunctions and starts smoking, forcing an emergency shutdown and leaving another Ampharos to take over elsewhere in the world. While Talonflame 2 still remains on course, Sophocles and Ampharos are dejected over this setback, fearing they did something wrong. Ellery reassures Sophocles that the machine will be fixed by the time of the next illumination and tells him and Ampharos to take a break until then.
Outside the Space Center, Ash and Goh try to cheer Sophocles and Ampharos up by complimenting the way they succeeded in guiding Talonflame 2 before the machine broke down. Sophocles starts to recover from his dejection quickly, but when Ampharos tries to illuminate its lights to entertain Grookey, it doesn't work. Goh figures that Ampharos must've fallen into a slump following its failure. Despite Sophocles trying to reassure Ampharos, the Light Pokémon suddenly runs away into the nearby woods. Ash, Goh, and Sophocles follow it, but end up losing it. Sophocles's confidence starts falling apart again, and he reveals that he isn't even Ampharos's Trainer, having borrowed it from his cousin Molayne from Hokulani Observatory for use in this project. Since he's failing to cheer up Ampharos, he's feeling he's being a nuisance to everyone else and starts to regret taking the invitation in the first place. Ash and Goh, however, tell him to get a hold of himself and remember to continue moving towards his goal of becoming an astronaut. Sophocles is cheered up by their motivational speech, only for the group to suddenly realize that Grookey has now disappeared as well. Goh guesses that it must've wandered off following what it thought was Ampharos's light, which is shown to be true as it catches up to a light that turns out to have come from a Volbeat instead of Ampharos.
While the group starts looking for Grookey as well, Cinderace ends up finding Ampharos, sitting dejectedly next to a rock. However, the rain that has just started to fall is making it hard to find Grookey now. Sophocles gets the idea to use light to find it, but Togedemaru's light proves too dim, and Pikachu's Thunderbolt doesn't last long enough to be of use. They realize Ampharos is their only hope, so Sophocles tells it how he tends to mess things up too, but he still never gives up on his dream. As such, he invites Ampharos to give another shot for its goal as well. This speech motivates Ampharos to try again, and its light successfully illuminates the surrounding woods, leading Grookey safely back to them. Sophocles then urges Ampharos to follow him back to the Space Center, which it happily does, although not without slipping on the rain-soaked ground first.
Back at the Space Center, Sophocles requests Ellery to let him have another go. Ellery happily agrees, telling him that the broken machine has been fixed. However, while everything is still being set up, Talonflame 2 ends up making an automatic evasive maneuver to dodge a meteoroid, which, while saving it, also puts it off the planned course and threatens to leave it unable to return. Sophocles makes some quick calculations and comes up with a plan that would allow cooperation between the four observatories involved in the project to guide the probe back to its proper course. The plan is put into action, and Talonflame 2 indeed starts gradually correcting its course. When the Mossdeep Space Center's turn comes, Ampharos illuminates itself once again, but the beam ends up being weakened by the clouds over the Space Center. As such, the group uses Pikachu's Thunderbolt, Togedemaru's Zing Zap, and Raichu's Nuzzle to give Ampharos more power, intensifying the beam enough to penetrate the clouds and reach Talonflame 2. The probe successfully reenters the atmosphere and breaks apart as planned while numerous people observe its fiery descent. Finally, only the sample capsule remains, and it safely floats to the ground with a parachute, bringing the Talonflame 2 project to a successful conclusion. Ash and Goh congratulate Sophocles and Ampharos, although the latter, along with the Pokémon that had provided power for it, have collapsed out of exhaustion.
The next day, Ash and Goh head home, encouraging Sophocles to continue working on his dream of becoming an astronaut. Sophocles, in return, gives his best wishes to his two friends and tells them to fulfill their dreams as well.