Storing ent

I need to get some unique call for the view ent, because I’m trying to make it so I can run away and have it strobe the entity I was viewing’s material.

Current Code:
[lua]
function Strober()
ent = LocalPlayer():GetEyeTrace().Entity
timer.Simple(5,
function()
ent:SetMaterial("")
end)
end
concommand.Add(“strobe”, Strober)
[/lua]

I know this won’t work, because it would call the entity I was viewing after 5 seconds.

No, it would work actually (although “ent” should be localized, because if you called strobe twice in < 5 seconds they would overwrite each other). When you create the variable ent, it is initialized to have the value of the entity of your eye trace. Thus ent contains a reference not to the TraceRes structure, but to the entity it initially contained.

In layman’s terms, ent gets the entity and keeps it. It would only not work if your timer function reset the “ent” variable.