Is it illegal to bring a gun to school?

Situation dependent. In most states, it's illegal to possess a firearm on K-12 property. In some states (such as North Carolina), only law enforcement officers are allowed to possess a firearm on any educational property (including university hospitals and other off-campus facilities). In others, concealed carry might be permitted on college campuses.