From the Super Mario Wiki
Electricity Shooters are devices that appear in the game Super Mario Galaxy 2. They are the yellow versions of the group of Shooters, with, like the others, a nozzle similar to F.L.U.D.D.'s. They appear in Space Storm Galaxy, in the mission "Follow Me, Bob-omb", in the Electric Field Area where the player uses the Pull Stars. They shoot homing orbs of electricity at Mario or Luigi, and if they are hit, they will fall and lose a wedge of health, and possibly fall into the black hole (the player can still quickly grab a Pull Star to stop Mario or Luigi from falling). The electric orbs are the same ones that the Undergrunt Gunner in Toy Time Galaxy and the Boomsday Machine in Bowser Jr.'s Boom Bunker shoot out. Prior to shooting, Electricity Shooters tend to charge up and glow, thus making it easy to predict their firing pattern.