The idiom "hit the roof" means to become very angry suddenly. Hence the cartoon scenes where a character becomes really angry and his/ her head starts steaming and they fly and literally hit the roof, if that makes sense to you.
Note that I was not positive of the meaning of this word until I searched for it, but I deduced it from the sentence you wrote. Reading more will help you acquire this skill, but reading in context can be very beneficial for understanding idioms and expressions.