Aliʻiōlani Hale (the Palace where H50 is headquartered and in real life the Hawaii State Supreme Court resides - not to be confused with ʻIolani Palace, which was the headquarters for the original H5O and is now a public museum) is from a (Show) security standpoint somewhat porous. In no particular order the entire building has been gassed; it's been taken over by a Mexican drug cartel, I believe a few people have been offed (at least one in interrogation?), and McGarrett, with the full weight of law enforcement coming in to arrest him after the Governor was murdered, was able to escape over the rooftop.
Non-metal weapons are a real and yet-to-be-solved problem, and I agree, the kid's backpack would have been searched and the gun held. It certainly would not have been allowed as carry-on in a plane, and really, toy guns need to fade away as A Thing.
I loved my cap pistol. I loved the smell of burnt caps. I grew up on Westerns and war movies. If I still had had it in the last thirty years, I would have "given" it to a landfill.