You need an event handler and you must tell the frame to use this handler.
Lua Code:
local frame = CreateFrame("FRAME", "FooAddonFrame");
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
local function eventHandler(self, event, ...)
print("Hello World! Hello " .. event);
end
frame:SetScript("OnEvent", eventHandler);
https://wow.gamepedia.com/Handling_events
To update the latency you maybe need an OnUpdate script.