OnTriggerStay for multiple seconds

Hey guys!
I have a character who I want to die if he is in a certain area for too long (4 seconds).
If he jumps out of the area (let’s say its a fire) I want the timer to reset. That would be easy, but my character can also turn invisible, in which case he also shouldn’t get killed by the fire and the timer should reset (because you can’t be burned if youre invisible.

I tried yield WaitforSeconds (4) but that didn’t work because you could hop in the fire for .1 second, turn invisible and then your invisibility could run out after 3 seconds and you change back and instantly die.

If anyone has an idea how to do this, Id greatly appreciate it!

You are not doing it correctly. You shouldn’t be waiting in the OnTriggerStay.
If you want you should increase time in the update loop and add a check in OnTrigerStay to know if you are exactly in the Fire and it’s been more than 4 seconds so that you can kill the player.