making entities dissapear after x seconds

I have [lua] g = ents.Create(“prop_physics”)
g:SetModel(“models/” … p … “.mdl”)
timer.Simple(40, function() g:Remove() end)[/lua]
it creates the prop but when it tries to remove it, it’ll give a “Timer Error: DeadGravity\gamemode\spawners.lua:38: Tried to use a NULL entity!”



i wanna say that its because your missing a , but the error says its working still but not seeing the ent.
[lua]timer.Simple(40, function(), g:Remove() end) [/lua]

actually, I think it may have been from some models I had it make, but they were static or dynamic or something because they didn’t want to spawn. it was the traffic cone and control room chair.

How can I make a prop disappear after it hits a npc?