Are you passing that function to a frame's SetScript method?
lua Code:
local f=CreateFrame("frame")
local myOnUpdate = function(self, elapsed)
self.t = self.t and self.t - elapsed or 1
if self.t < 0 then
self.t = 1
print("hi")
end
end
f:SetScript("OnUpdate", myOnUpdate)