The people who are committing these crimes do not seem to give a about the punishment. In fact, they know they will most likely die in the act or get the death penalty later. Look at the face of the kid in Chicago -- the kid was mentally checked out. Watching an execution on tv wasn't going to stop him or the Uvalde kid.
Anyway, what you're suggesting is just another way of dancing around the problem... the easy access to guns.