The Decepticon scientist who transforms into a ray gun is Shockwave.
Shockwave is the highly logical Decepticon scientist and weapons designer associated with a giant Cybertronian laser or ray gun in Generation 1. His signature trait is emotionless calculation: unlike the ambitious Megatron or treacherous Starscream, Shockwave is typically portrayed as a cold strategist who values logic, experimentation, and military efficiency.
In the original G1 cartoon, Shockwave remains on Cybertron while Megatron and the other Decepticons pursue the Autobots to Earth. He acts as Megatron’s loyal viceroy and helps maintain Decepticon control of the homeworld. His weapon mode is unusually literal for a Transformer: a large futuristic energy weapon rather than a car, aircraft, or ordinary Earth device.
Continuities differ in both his role and alternate form. Later stories may depict Shockwave as a tank, spaceship, artillery platform, or other heavy weapon. Megatron is the better-known G1 gun Transformer, but he transforms into a Walther P38-style pistol, whereas Shockwave’s classic form is a large one-eyed Cybertronian ray gun. Soundwave, another common mix-up, traditionally transforms into a cassette recorder.