Checking if a player is looking at a prop for x amount of time.

I have a trace set up already.

I just need to find if a player is looking at a prop for x (let’s say 6) amount of time, if he looks away then the timer resets. If he doesn’t, a function gets called.
I know there’s Propblower which I saw somewhere and was going to look at, I think it was on facepunch but I cannot find it anymore.
Here’s my trace:
[lua]
local st = self.Owner:GetShootPos()
local en = st+(self.Owner:GetAimVector()4096)
local fl = {self.Owner,self.Weapon}
local tr = Egon_GetTraceData(st,en,fl)
local ent = tr.Entity
if SERVER then
if IsValid(ent) then
if ent:GetClass() == “shield” then
ent:Hit(self.Weapon,tr.HitPos,1,-1
tr.Normal)
end
end
end
[/lua]

Use a think hook with a check every second (to not bog it down). Check if the trace entity is the same as the last one, if so, store it in something like ply.LookingAtEnt = ent and ply.EntLookTime = CurTime() (ofc making sure to not overwrite the time if already set)

Then, if ply.EntLookTime + SomeInt > CurTime() do the hit

Think hook check:
[lua]local nextCheck = CurTime()
hook.Add(“Think”,“Check Example”,function()
if CurTime() >= nextCheck then
nextCheck = CurTime() + 1
print(“This appears every second!”)
end
end)[/lua]

Thanks I’ll be sure to try it.
I understand CurTime() is time the server was up, if so why do people set variables equal to it without the intention to do something every second or etc.

It provides a reference point to a specific time that won’t be repeated in that session again.

Basically it’s like doing this:

x = CurTime() – x is now equal to 2:00
y = CurTime() + 60 – y is now 60 seconds after 2:00, or 2:01
if CurTime() > y then do stuff end – if the time is after 2:01, do something

When the server starts CurTime() is 0 and counts up for ever second. For something like os.time it outputs the time of day which can change if the system clock changes, while CurTime will not.