GamerDude96, a Boolean variable as mentioned by Maverick1912 is a good way to handle this issue but requires you to code when to disable it. I prefer to use an integer variable that stores the time to end invulnerability. When the character becomes invulnerable, you would set:
invulnerableUntilTime = time + X seconds
Then, when damage would be dealt to the character, you would check if:
time > invulnerableUntilTime
With a Boolean, you still have to set the value and check it but this completely removes the need to set the Boolean value to false. By nature of the passage of time, the invulnerability will be remove.