It seems like you're trying to express something like:
* "The class became hilarious *while* the teacher was out."
In this case, "while" acts as a conjunction that shows a contrast or simultaneous occurrence. It connects the two clauses:
* "The class became hilarious" and
* "the teacher was out".
The sentence means that the class was funny because the teacher was absent.