This object exists primarily within the Adventures of Sonic the Hedgehog continuity. Information in this article may not be canonical to the storyline of the games or any other Sonic continuity.
The Stupidity Ray is a gun that Dr. Robotnik invented, which makes victims stupid. It does not work on Scratch, because it couldn't make him any dumber than he already was. Sergeant Doberman and Wes Weasely wanted the Stupidity Ray because it would make it easier for them to reach their goals (Doberman could use it to recruit new soldiers with the recruits too dumb to object to his orders and Wes Weasely could use it to make everyone too stupid to see through his scams). In the end, it was destroyed by Sonic, but not before the ray is used to make Robotnik into an idiot. Sgt. Doberman and Wes Weasely both fortunately agree with Sonic that it is better off that the Stupidity Ray was destroyed, because Doberman states that the most useful soldiers are intelligent ones anyway and Wes Weasely states that scamming people wouldn't be very fun if everyone was too easy to fool.