"The Loophole" is the tenth episode of Season 5 of The Amazing World of Gumball. It is the 166th episode overall.
Gumball and Darwin give Bobert instructions so he will behave in a safe and responsible manner, but he applies his logic to their rules.
The episode begins with the children walking out of class; once again, it has been a tiring class, and Miss Simian has been of no help in the students' understanding of the concepts. Gumball tries to explain to his teacher that homework is pointless if the students don't even know what they're doing. Unsurprisingly, Gumball's complaints prove to be futile when Miss Simian symbolically shows just how apathetic she is to Gumball's complaints by having a shredder shred any complaints in the suggestion box.
Shortly after, Gumball walks toward Darwin and Bobert, and he sees how quickly Bobert is able to complete his homework. This upsets him even more and prompts him to rant to Darwin about how he just does not even work anymore and that he wants to "go straight to the end." Bobert overhears this rant and taking Gumball's words literally, proceeds to blow up Gumball's head. Once his head regenerates, Gumball realizes just how dangerous Bobert is; he and his brother conclude that they must reprogram Bobert in such a way so that he won't be such a walking danger to others, with the added benefit of free homework answers from Bobert, of course.
Later this day, the Watterson brothers take Bobert to their room in an attempt to give Bobert commands that will prevent him from hurting anyone. Despite their best efforts, the wording of the brothers' commands allows Bobert to find some alternative method for hurting a subject, specifically Gumball. Numerous attempts and a bruised Gumball later, Darwin finally finds the correct words to stop Bobert's violent attacks.
After his success, Darwin heads to kitchen to grab a snack; Gumball and Bobert follow, with Gumball not being very happy about Darwin's choice to use him as guinea pig earlier. Ironically enough, Darwin just happens to begin choking on his food. Gumball is quick to act, but Bobert does not allow Gumball to save Darwin, for he says that Gumball's way of saving him may potentially hurt the fish's spinal cord. Realizing that time is imperative, Gumball gives Bobert the command to save Darwin in any way possible. A random algorithm determines that Bobert will save Darwin by inflating him; of course, Gumball is not amused.
The trio head to the mall where Gumball gives Bobert the command to simply uphold the laws. However, once the command is integrated, Bobert finds the most ridiculous and absurd laws to enforce. In an attempt to stop the madness, Gumball tries to reason with the robot; this only leads to Gumball "obstructing justice" that triggers a chain of events that lead to Bobert infinitely assaulting himself. Gumball then tells Bobert not to uphold the law, seeing how ridiculous some of the laws can be, and unsurprisingly, Bobert once again takes that command too literally.
The hours are running low, and the Watterson duo is ready to accept that Bobert is just a potential fatal hazard and that there is not much they can do to fix it. Bobert too is ready to give up, preparing to delete all his files; Gumball tells him to stop, as he believes all lives must be protected. These words give Darwin the brilliant idea to command Bobert to protect all life no matter whom it is. The robot integrates the command to his system, and to their surprise, the command is successful; Bobert is no longer a threat.
Now with a purpose, Bobert tries to analyze his environment to search for potential dangers. As he continues to inspect his area, he notices that all these life endangering problems are the doing of the people. He concludes that there is only one way to protect all life: exterminate all of "mankind."
With the Bobert problem solved, Gumball and Darwin return to their current homework dilemma; out of options, Gumball decides he will just search for a person on the Internet that can help him complete his homework. As Gumball begins to use his phone, he notices that there is no Internet service, but before he can start rationalizing on a reason why both Darwin and he take notice to Mr. Small's and Larry's disagreement on the correct pronunciation of "quinoa." The men decide to settle their disagreement on the Internet, but they too lack service.
Simultaneously, Principal Brown and the goblin discover that everyone is without money. With society on the verge of collapsing, they and other residents begin to adapt a "survival of the fittest" mentality. This rapid deconstruction of "mankind" prompts Gumball to call the emergency services. However, when Gumball calls the number, he is redirected to Bobert, who reveals that this whole tirade was part of his elaborate scheme to kill off "mankind."
Quickly, the Watterson brothers rush to Bobert's basement to reason with him. It is in this location that the duo finds out that Bobert has retooled himself into a massive ticking time bomb made to wipe out all remains of "mankind" making it only more imperative that the boys try to rationalize the consequences with him. Of course, Bobert refuses to stop as he is set to "protect mankind'" as the boys walk away saddened by their upcoming demise, Gumball and Darwin think over Bobert's words again. With seconds to spare, the two realize that Bobert cannot hurt "mankind," for doing so would mean he's hurting a form of life.
Recognizing his error, Bobert immediately stops himself. Gumball and Darwin are relieved, and promptly ask Bobert for homework help, ending the episode.