You was holding the handgun, she was giving birth
A sandbox is also, of course, where kids play. Kendrick draws attention here to how kids are thrust into an adult world too early — having to deal with violence (the handgun), teen pregnancy (the birth), and other ills. Also note the contrast between the gun which takes life and giving birth which gives life. .
Some have suggested that the “you” here is Kendrick’s father/incarcerated uncles and the “she” is his mother. The fact that they are in the sandbox with him suggests that they might be his peers. .
To help improve the meaning of these lyrics, visit "Cartoon & Cereal" by Kendrick Lamar (Ft. Gunplay) Lyrics and leave a comment on the lyrics box