Kill player when touching an entity help?

So, firstly i’m new to lua.

What I need help with is when a player touches an entity for a certain amount of time, the player is killed. Say player1 touches the entity func_door, for 20 seconds, after 20 seconds player1 is killed. I’m not necessarily asking for someone to code the whole thing, just something to start with atleast please?

You could probably star a tmer on ENT:Touch() and get the entity that is touching. Take a look at timer.Simple a gmod wiki. I think it might help you.
I am noob too, so I may be wrong.

Yeah that would be the best thing to do but the problem would be that it would need to check if the player is still touching it after 20 seconds since the timer would not be destroyed, its fairly easy to do but the best thing is to try do it yourself to learn

Maybe to check every sec if the player is touching and if not, restart?

In the ENT:Touch hook:
[lua]if !self.dieTime then
self.dieTime = CurTime() + 20

if(self.dieTime < CurTime() and IsValid(player.GetByID(1)) )then
self.dieTime = nil

In the ENT:EndTouch:
[lua]self.dieTime = nil[/lua]

Something like that.