Elon Musk sent engineers to Thailand before traveling there himself and working to build a child-sized submarine to assist the rescue operation for the 12 boys and their soccer coach who were trapped in a cave.

Some have criticized his involvement as a public-relations stunt, and many have joked about the submarine being deemed "not practical" by those leading the rescue mission.

Musk on Tuesday posted what he said was a conversation with a leader of the dive team that showed the submarine was desired, and he said he was leaving it there in case it could be of use in the future.

He also commented on those criticizing him: "Something's messed up if this is not a good thing."

Elon Musk has hit back at those who have criticized his attempts to help recuse the 13 members of a Thai soccer team who were trapped in a cave for more than two weeks.

Musk tried to help in a variety of ways, including traveling to Thailand, sending engineers to the country, and building a child-sized submarine.

He said on Twitter on Wednesday that the reaction had "shaken my opinion of many people."

"We were asked to create a backup option & worked hard to do so," Musk tweeted. "Checked with dive team many times to confirm it was worthwhile. Now it's there for anyone who needs it in future. Something's messed up if this is not a good thing."

He was replying to another Twitter user, who wrote: "The hatred being spewed about @elonmusk is ridiculous. Any engineer always needs a backup plan. He tried to help in the best way he knew how, and I commend him mightily for it."

Musk's submarine was deemed "not practical" for the mission by Narongsak Osatanakorn, the head of the joint command center who coordinated the operation. But Thai Prime Minister Prayut Chan-o-cha said he was "highly appreciative" of Musk's efforts.

Musk also described how the dive team encouraged him to keep working on the submarine. In a response on Twitter to a BBC report about Osatanakorn's comments, Musk shared what he said was his email correspondence with Richard Stanton, a British diver who helped lead the mission.

The photo of the emails shows that Stanton told Musk on Saturday that the submarine "may well be used" as part of the rescue mission.

—Elon Musk (@elonmusk) 10 July 2018

"SpaceX engineering is absolutely certain that mini-sub can do entire journey & demonstrate at any time," Musk said in another tweet.

Some Twitter users have joked about Musk's contribution, implying that he didn't do anything to help with the rescue.

—David Mack (@davidmackau) 10 July 2018

But others have defended his efforts and use of his time and his companies' resources to help with the mission.

Business Insider's Leanna Garfield argued that Musk's contribution to the rescue worked as a huge public-relations boost to his companies: "Most of the world will not remember the names of the Thai SEALs who risked their lives on the ground to save the soccer team. But they will remember Musk."

On Sunday, Musk hit back at a Twitter user who accused him of using the crisis as PR stunt.

"Gosh, feel like you need to leverage every public situation for your own aggrandizement much?" the person wrote. "You do know there are hundreds of experts already working this across multiple counties, no? #narcissism."

—Elon Musk (@elonmusk) 8 July 2018

"If I am a narcissist (which might be true), at least I am a useful one," Musk replied.