The PJ Masks join Thomas and his friends on a quest to find hidden treasure.
Opening/The Nighttime Villains
The film opens at the coastal side of Sodor. Patrons argue amongst themselves as a weird red mist swirls around their feet. Sitting on the beach, three PJ Masks characters sing as the red mist flows into the blue gem necklaces. The blue nighttime villain, Night Ninja, complains that he's "Tired of fast food" and needs a meal. The black and white haired boy Romeo laments that the magic in this world isn't the same as in where they come from. As the silver haired girl, Luna Girl, joins in the conversation getting into a slight argument with Night Ninja, Romeo notices a Ninjalino pointing to something outside. Romeo runs out to see a small blue tank engine turn into a robot, grinning evilly when he realizes who it is. He explains to Night Ninja and Luna Girl that OpThomas Prime has found his way to Sodor and plans to use his power to make Ryan and the inhabitants of the world adore them.
Thomas and Bertie's race
Six moons later, Thomas is chuffing along his branch line. He tell Clarabel to keep an eye out for Bertie, nothing that he doesn't want him taking him by surprise. Clarabel and Annie tell him to stop thinking about racing and keep his eyes on the rails, which he immediately stops doing when he spots Bertie. Bertie sees him and they start racing. Despite getting out of various mishaps along the way, Thomas wins. Annie tells Thomas that Sir Topham Hatt and Princess Celestia don't approve of him racing. Thomas says "What do they know?" and that he's been racing on his branchline for years. Soon enough Bertie arrives. He grumbles that he's always getting stuck behind slow vehicles ever since they started on a new branchline. It's being built in Arlesdale all the way to Harwick. Annie and Clarabel fear their branch line will be closed in favour of the new one, but Thomas dismisses it; He thinks that their Branch Line is the most important part of the whole railway, and he’ll always be the Fat Controller’s No.1 engine!
Marion meets Oliver, Mike, Rex and Bert
Marion, the railway steam shovel, is on her way to help with the construction of the new branch line. But something whizzes by, startling her. She shuts her eyes, and bumps into Toad and Oliver, who are waiting at the ballast chute. A small red engine races up the chute with some hoppers, frightening Marion. Toad introduces Marion to Rex, Mike, and Bert, three miniature engines. Marion is interested by the little engines' size, asking if they are real. A cross Mike tells her they are real, and that they deliver ballast, wool, and passengers for the big railway. Toad and Oliver then leave for the construction yard, just as a black tender engine races past Marion.
At the construction yard, Duck is shunting trucks, just as Donald and Douglas arrive. Duck is delighted to see them, remarking that it has been ages since he has last seen them, but the twins tell him they have only been away to fetch new rails and sleepers for the construction. Meanwhile, Jack and Alfie are getting to work, just as Oliver arrives, apologising for being late as he took a wrong turn. Later, Thomas visits Amaya, Connor and Greg.
Accident at Knapford/Marion meets Oliver the Excavator
The next morning, Thomas cannot wake up. His fire goes out, and there is not enough steam to get him going. The other engines all wake him up, reminding him that he needs to shunt Gordon's coaches, but Thomas is in no hurry to do that. Meanwhile, Gordon grumpily waits at Knapford for Thomas, just as he finally arrives. Annie and Clarabel remind Thomas it is time for their first train, but Thomas tells them he has to get Gordon's coaches first, criticizing Gordon for being lazy for not getting his own coaches. Gordon tells Thomas that he knows full well that tender engines are too large for shunting, telling him that is what common little tank engines do. Determined to prove Gordon wrong, Thomas decides that he will pull the express today, and thunders out of the station with the coaches. Gordon gives chase, and Thomas tells him if he wants his coaches, he’ll have to catch him first! But Thomas’s confidence is shortlived when Toby calls out to him. He doesn’t realise Emily is coming into his path, and she brakes hard to avoid hitting the coaches. Thomas stops abruptly and the entire compliment of Express Coaches fly off the track and land in a heap all over Knapford Station yard – halting all traffic in and out of the station.
Meanwhile, at the construction site, Marion tries to play 'Guess What's in My Shovel' with Donald, but he does not have time to play. She then turns her attention to Oliver the excavator, but he tells her that all he has in his bucket is dirt and rocks. When she asks what his name is, Marion is surprised to find out that the excavator's name is Oliver, believing that he turned himself from a railway engine into a digger. Oliver tries to explain the situation to her, but his attempts to do so are futile, as she believes the Arlesdale engines really are magic and granted him a wish, deciding that she will make a wish as well.
Thomas' punishment/Meeting Ryan/Unsafe cutting
Back at Knapford, the Fat Controller has arrived to inspect the damage. Thomas tries to pin the blame on Gordon and Emily, but the Fat Controller does not believe him. He tells Thomas that he will be sending him to the construction yard as punishment. When Thomas asks who will look after his branch line, a new purple tank engine called Ryan shows up. The Fat Controller welcomes Ryan to his railway, while Thomas looks on, shocked. Connor, Greg and Amaya visit Thomas and comfort him after the accident. Connor says that the accident wasn't Thomas' fault.
At the construction site, work goes on as usual. However, trouble arises when the ground beneath the tracks begins to crumble, and the workmen flag down Donald just before he can pass over the line. Some engineers are called, and after inspecting the area of bad track, they deem it unsafe, forcing the workmen to re-route the line.
Never Overlook A Little Engine (Scene)
Connor, Gred and Amaya comfort Thomas. Meanwhile at Arlesburgh Junction the small engines are delivering ballast for the new branch line, when Thomas sadly puffs in. When asked what is wrong by Bert, Thomas crossly tells them about Ryan replacing him and what Gordon told him. The small engines tell him that bigger engines always act superior than smaller engines, even if they come out on top. The small engines then burst into song to cheer Thomas up, but unknowingly make him overconfident. When Thomas arrives at the construction yard, he remembers what the small engines told him about rails and sleepers coming before ballast, and eagerly shunts some flatbeds of sleepers and rails along to the construction site. The workmen try to stop him from travelling along the unstable track, but Thomas thinks they are cheering for him. He bursts through the safety barriers and rolls over the unstable ground, just as it gives way and a large sinkhole forms. Thomas tries to escape the hole, but the trucks pull him in as his crew jumps clear. Thomas is badly damaged by the fall, but sees an abandoned pirate ship in the cavern. Connor, Greg and Amaya arrive and ask Thomas if he is alright.
Thomas is rescued/Steamworks/At the sinkhole/Marion makes a wish
At Knapford, Ryan arrives in the yard, introducing himself to Annie and Clarabel, who wonder where Thomas is. Meanwhile, at the cavern, Thomas is lifted out by Rocky, the Fat Controller reprimanding him for ignoring the danger signs. Thomas tries to tell the Fat Controller he was not responsible for the accident and tries to tell him about the pirate ship, but the Fat Controller is not interested in his excuses, telling Emily to send him to the Steamworks. As this goes on, an elderly man watches Thomas being recovered from the cavern with his telescope, stomping on his sailboat for bobbing about in the water. Unfortunately he runs into Romeo, Luna Girl and Night Ninja who offer to help him.
Thomas is sent to the Steamworks, but is in no hurry to get back to work, telling Victor and Kevin that the Fat Controller has already replaced him. However, Victor reassures Thomas that the Fat Controller would never replace him, and that he wants him to get back to work as soon as he can, while Kevin tells Thomas that despite all his accidents, he still works at the Steamworks. Just then, Edward arrives and tells them that Rocky has discovered the pirate ship, much to Thomas' fury. At the sinkhole, Rocky lifts the pirate ship out, much to everyone's amazement. Jack believes that the ship was put into the cavern by being folded up like a ship in a bottle, but Donald and Douglas dismiss Jack's theory, believing that the cavern must once have been open to the sea and the ship must sailed in then. Marion believes that if there is a pirate ship around, then there must be buried treasure. This gives her an idea for a wish, and she sets off to Arlesburgh Junction at once.
At the junction, the small engines are still at work, just as they hear Marion coming. Both Rex and Bert immediately flee, leaving Mike to escape for himself. Before he can get off of the chute, however, Marion stops him and begins telling him her wish. Mike immediately breaks free and escapes, but this only fuels Marion's belief that the small engines are magical. Meanwhile, Donald and Douglas deliver the pirate ship to Arlesburgh Harbour, the same man and sailboat from earlier watching them with Romeo telling him about the pirate ship. Night Ninja and Luna Girl look at each other evilly, knowing that their chance of getting OpThomas Prime's power is near. Romeo smiles also.
Meeting the other good guest stars
Later, at the steamworks, the other good guest stars show up, and they tell Thomas not to be upset. Ryan thinks of an idea then he, the Dazzlings and their friends sing Better Then Ever to cheer Thomas up. They gain pony ears, wings, Cybertronian Armor and longer hair as they sing.
Night/The Lost Pirate/Ryan at the construction site/Bad coal
That night, Henry is pulling the Flying Kipper, when he suddenly sees a white sailboat gliding down the rails. Surprised, he runs down a siding and hits the buffers, but when he looks back, the boat has gone. The next morning, he tries to tell the other engines at Brendam Docks, but most of them think he was just seeing things. Salty then shows up and tells the engines the legend of the Lost Pirate, Captain Calles, who was a feared pirate who stole much treasure from merchant ships. However, his activites gained attention from the Navy, who hunted him down. To escape from them, Calles sailed his ship into a cavern and buried his treasure nearby. However, his map revealing the location of the treasure was lost, and he never found either the map or the treasure again. Salty says that the Lost Pirate is still out there on his ghostly ship, trying to find his treasure, but Cranky scoffs at the idea of a ghost pirate. The other engines all leave, with Henry still protesting that he saw the ghost. Meanwhile, Thomas passes through Arlesburgh when he sees the pirate ship, angrily saying that he was the one who found the ship, not Rocky. While he is not looking, the man from earlier climbs onto the ship and looks around.
Thomas arrives back at the construction yard and fills up on coal, surprised to find Ryan there. He asks the Fat Controller if he can now go back to his branch line, but the Fat Controller tells him that Percy is already doing his work, and tells Thomas to collect some more ballast, leaving Thomas to lament at the fact he is no longer the Fat Controller's No. 1 engine. Meanwhile, Marion is helping Oliver and Alfie dig at a cliffside, telling them about how she made a wish to Mike.
When Thomas arrives at Arlesburgh Junction, he is blowing sparks and black smoke from his funnel. The small engines conclude that he must have had some bad coal. Even Connor, Greg and Amaya notice.
Thomas meets Sailor John, Skiff and the Nighttime Villains and shows his robot self
That night, he takes on some fresh coal and heads to the sheds, but finds Ryan already there. Ryan tries to coax Thomas into the shed, but Thomas chooses to sleep on a siding by himself, upsetting Ryan. As he sleeps on a siding, he suddenly wakes up to see a sailboat sailing along down the line and a girl following it on a moon shaped board, so he decides to follow after them. Thomas stops at the sinkhole to find the sailboat and its owner there, accidentally getting their attention. The man turns his attention to Thomas, and asks him who he is, to which Thomas introduces himself and mentions how he found the pirate ship, but Rocky stole the credit from him. The man introduces himself as Sailor John, while his sailboat also introduces himself as Skiff, telling Thomas that they are looking for treasure. Connor, Amaya, and Greg are surprised to see their enemies there too. After a demonstration of his robot form, Sailor John asks Thomas if he would like to help him find the treasure, to which he agrees to. Tying a harness around his waist and to Thomas' buffer, Sailor John lowers himself into the cavern. Skiff tells Thomas that they have been sailing around the coast for years to find the treasure, as well as telling Thomas about how Sailor John gave him rail wheels to search for the treasure on land. Sailor John finds Calles' map inside of the cavern, and is pulled back out by Thomas. Skiff reminds Sailor John that the sun is rising, and John tells Thomas that he and Skiff have to go back home, telling him they forgot their shovels. Since Skiff cannot move due to there being no winds, Thomas pushes him along back to the harbour, where he sails off with Sailor John back home. Connor, Greg and Amaya become supsicous of why their enemies were nice to Thomas.
Morning/Sailing For Adventure
Later that morning, Thomas returns back to the construction yard, just as Ryan begins questioning him on his whereabouts the previous night. Thomas tells Ryan that he must have been having a dream, and then questions him when he begins to fill up with coal. Thomas knows fully well that the coal in that hopper is bad, but does not say anything to Ryan about it. the song Sailing for Adventure plays. Thomas then asks Connor, Greg and Amaya to keep his robot identity a secret. They promise to and cross their hearts to show so.
Dynamite/Thomas saves Ryan & the construction site as OpThomas Prime and nearly gets punished again
Meanwhile, Marion tries to work on the next cutting, but the rock is too hard. When told that they have to wait for a train of dynamite from Brendam Docks, Marion suggests to Oliver that he should make a wish and turn back into an engine, but Oliver, going along with what Marion says, tells her that may not work. When Ryan returns, he is emitting black smoke and sparks from his funnel. Just as he begins to puff away, sparks from his funnel set the dynamite in one of his trucks alight, leading him to panic. This causes him, Jack, Alfie and Marion, alongside the guest stars, to pass around a crate of dynamite with a lit stick, until it lands back into the trucks, which Marion shoves away. Thomas quickly puffs off to become OpThomas Prime and grabs the dymanite, runs to the edge of the cliff and throws it into the ocean. There, it explodes, creating a massive spray of water. He is congratulated by the others, but the Fat Controller is extremely cross, thinking that Thomas was wasting the dynamite. However, Connor, Greg and Amaya, remembering their promise, state that Thomas wasn't there at the time. The Fat Controller soon realizes his mistake and congratulates OpThomas for saving the day, and tells Connor, Amaya and Greg that if they see Thomas, they should tell him that he wants a word with him. The diggers attempt to continue work on the cutting, but without dynamite, work is slow. Marion finds a chest in the cliffside and tries to tell Alfie and Oliver, but by then, they have already left. Thomas meanwhile wants to talk to Ryan and they go somewhere private to do so. Thomas tells Ryan that it was him who saved him as a robot yesterday and makes him promise not to tell anyone. Connor arrives and tells Thomas that the Fat Controller wants a word with him.
The Fat Controller's talk
Romeo, meanwhile, chats with Luna Girl and Night Ninja. He tells them of their plan to take the pirate ship. Luna Girl says that she knows that Catboy, Owlette, Gekko and OpThomas Prime will come after them to get it back. Thomas meets the Fat Controller at Knapford. He tells Thomas of how lucky he was that an accident was prevented, but at the cost of losing the dynamite, and asks if he knows anything about it. Thomas says no and wonders if he knows anything about a treasure map, confusing Sir Topham Hatt. Thomas then asks if the incident had anything to do with OpThomas Prime, because he heard news that he had shown up and saved everyone at the construction site.
We make a team together
That night, Thomas rests on a siding, just as he sees Skiff and Sailor John heading back to the sinkhole. He follows after them and agrees to help them try to find the treasure. But no matter where they look, they cannot seem to find them. Sailor John immediately accuses Thomas of finding the treasure first, citing that only they and Skiff have seen the map, and he has been with Skiff night and day. Skiff reminds Sailor John the sun is rising, and Sailor John leaves as Marion wakes up. Connor, Greg and Amaya become more supsicous of their enemies.
The treasure is found/Confronting Sailor John & the villains
Upset, Thomas puffs away, but Marion bumps into him, causing her to dump the chest on him, revealing its contents - the treasure! The Fat Controller is delighted with Marion's discovery and plans to display the treasure in the museum, while he sends Thomas to the waste dump to deliver some construction waste.
As Thomas puffs along the cliffs, Henry thunders past, frightened by the Lost Pirate. As he rounds the bend, Thomas finds that the Lost Pirate is actually Sailor John and Skiff. Sailor John demands to know where the treasure is. Thomas tells him that the Fat Controller has it and plans to give it to the museum, infuriating Sailor John, despite his previous claims to Skiff that the treasure would go there. Sailor John angrily proclaims that he will get the treasure back, but Thomas and his friends all stand up to him, shoving him and Skiff aside, leaving John to pout. Romeo tells Salior John that he has a plan and is going to be really easy.
The Pirate ship is missing
The next day, Thomas, Connor, Greg and Amaya discover that the pirate Ship has gone missing. That night they investigate it's disappearence as Catboy, Owlette, Gekko and OpThomas Prime but can't find it anywhere.
Sailor John steals the Treasure/The Nighttime Villains capture Ryan
Meanwhile, Sailor John steals the Treasure and the Nighttime villains interrogate Ryan into telling them the location of OpThomas Prime. He tells them and they set off immediately.
Treasure Chase/Sailor John is caught
At Tidmouth Sheds, Henry races past, frightened by Skiff and Sailor John, who follow along shortly afterwards. Annie and Clarabel believe they are having a strange dream, until Thomas thunders past, chasing after Sailor John and Skiff. Thomas heads up a hill, where he finds the pirate ship there and tied to Skiff. Sailor John picks up the anchor and lets the ship roll down the hill. As the PJ Masks take on the villains, Luna Girl reveals that Robert Callaghan is her uncle. Meanwhile at Arlesburgh Junction, Ryan's worry about why Thomas stayed at Knapford prevents him from sleeping, and he panics when he sees the ship approaching. Thomas passes by, and tells the small engines to stop the ship. Though Sailor John scoffs at the engines' miniature size, the three small engines bravely push some ballast hoppers off of the chute and onto the standard gauge line. Most of the hoppers are shoved aside, but one gets stuck under the flatbed and causes the pirate ship to slow down and lose momentum. A rope then gets fastened to Ryan's buffer, and the tank engine suddenly brakes, hitting a buffer stop and causing the ship to topple over. Thomas congratulates Ryan and puffs on.
As the morning sun rises, the chase is still going on. Thomas tries to tell Skiff to stop, but he cannot. Sailor John tries to stop Thomas, attempting to throw an anchor and shovel at him. He then tries to destroy Thomas by blowing him up with dynamite, but Skiff tips over slightly, causing John to lose his aim. Skiff encourages Thomas to derail him, just as John violently hits Thomas in the face with the oar, threatening to have Skiff in the dry dock sail-less. Thomas furiously bumps into Skiff, but accidentally sends him down a different line, much to Sailor John's delight. Though it seems as if there is no hope left, Thomas suddenly notices that his line crosses over Skiff's, immediately picking up speed and ramming into him. Skiff is re-railed onto Thomas' line, but their relief is short-lived, just as Thomas notices the line runs into the sea. Thomas falls into the sea and rests atop of Skiff's chassis, while Skiff and Sailor John sail away. Skiff tries to tell Sailor John to go back and help Thomas, but John threatens to destroy him if he tries to betray him. Suddenly, a wave pushes them along and causes them to lose the oar. Sailor John orders Skiff to stop it, telling him he is letting in water, but Skiff tells him that the treasure is too heavy and is making him sink, telling John to throw it overboard. Sailor John does not want to and forces Skiff to sail on, just as a huge wave forms. Skiff is capsized by the oncoming wave, and the treasure chest sinks to the bottom of the sea. Thomas watches on from the harbour, thinking this is the end of Skiff, just as Skiff turns back over.
Later that morning, the police rescue Sailor John and arrest him. Thomas is lifted onto a flatbed by Rocky, and upon seeing the Fat Controller, he tries to apologize, thinking that he would be cross with him. However, the Fat Controller tells Thomas that he is proud of him for trying to stop Sailor John and that Ryan and the PJ Masks told him everything. Thomas is still upset that the treasure is lost, but the Fat Controller is not concerned about that, telling Thomas that his engines are more important to him than any old treasure, and that Thomas is his No. 1. Thomas smiles, and his number is shown to be back. Connor, Greg and Amaya say that Thomas proved that he was a hero even when not in his robot form and the Nighttime Villains, upset that their pendants have been destroyed, escape.
Daisy Returns/Better Than Ever/Happy Ending
At last, the construction of the new branch line running to Harwick is now complete. Marion finds out that there are, indeed, two Olivers on Sodor, and Thomas, fully repaired, arrives with Annie and Clarabel for the opening ceremony. The Fat Controller announces that Ryan will be handling the goods traffic, while an old friend looks after the passengers. Thomas says he already has a branch line, but the old friend is revealed to actually be Daisy, surprising Amaya. The branch line is declared open, and Thomas and the other engines steam along down the new line, meeting up with Skiff again, who is now carrying railboat tours. divers recover the treasure, and that night, Thomas and Skiff watch from the harbour as fireworks go off. As the credits roll, the Rainbooms, Matau and the Skylanders, the Cyberlings and Ryan and the Dazzlings perform Better Than Ever. In a post credit scene, a Decepticon Pirate named Saberhorn rises from the ocean. With him is Matau's older brother Captain Gutt. They want to help Sailor John take revenge on Thomas as the film ends.
- Ryan F-Freeman, Meg Griffin, Brian the Crocodile, Cody Fairbrother, Mordecai, Rigby, Crash Bandicoot, Coco Bandicoot, Crunch Bandicoot, Iago, Captain Hook, Mr. Smee, Peter Venkman, Matau T. Monkey, Winston Zeddemore, Ray Stantz, Egon Spengler, the Cyberlings, Mickey Mouse, Oswald the Lucky Rabbit, the Mad Doctor, the Dazzlings, Gremlin Gus, Sci-Ryan, Sci-Twi, Spike the Dog and Sector V will be good guest stars in this film.
- Robert Callaghan, Stickybeard, Gremlin Prescott, Nina Cortex, and Dr Neo Cortex will be bad guest stars in this film.
- Robert Callaghan, Stickybeard, Gremlin Prescott, Nina Cortex, and Dr Neo Cortex will work for Sailor John and the Nighttime villains.
- It is revealed that Sailor John is Stickybeard's cousin.
- Luna Girl reveals that Robert Callaghan is her uncle.
- Ryan will reveal that Romeo is Dr Neo Crotex's brother.
- Rainbow Rocks
- Better Then Ever
- Battle of the Bands
- Ghostbusters theme song
- Never Overlook a Little Engine
- Everything is Awesome
- Under Our Spell
- Help Me, Help You
- Sailing For Adventure
- We Make a Team Together
- Awesome as I Wanna Be
- You Are a Pirate
- The Mad Doctor Isn't Mad
- A Parrot's Life for me
- Welcome to the Show
- The Fall of Prescott
- My Past Is Not Today
- Tricks Up My Sleeve
- Friendship Burns Bright
- You Wouldn't Know
- Opening/The Nighttime Villains
- Thomas and Bertie's race
- Marion meets Oliver, Mike, Rex and Bert
- Construction site
- Accident at Knapford/Marion meets Oliver the Excavator
- Thomas' punishment/Meeting Ryan/Unsafe cutting
- Never Overlook a Little Engine (Scene)
- Meeting the other guest stars
- Thomas goes down the unsafe area and discovers a pirate ship
- Thomas is rescued/Steamworks/At the sinkhole/Marion makes a wish
- Night/The Lost Pirate/Ryan at the construction site/Bad coal
- Thomas meets Sailor John, Skiff and the Nighttime Villains and shows his robot self
- Sailing For Adventure
- Dynamite/Thomas saves Ryan & the construction site as OpThomas Prime and nearly gets punished again
- We make a team together
- The treasure is found/Confronting Sailor John & the villains
- The Pirate ship is missing
- Catboy, Owlette, Gekko and OpThomas Prime investigate
- Sailor John steals the treasure/The Nighttime Villains capture Ryan
- Treasure chase/Sailor John is caught
- Daisy returns/Better Than Ever/Happy ending