You need to wait until ADDON_LOADED until your savedvariables are available
https://wow.gamepedia.com/Saving_var..._game_sessions
Something like this
Lua Code:
local Congrats_EventFrame = CreateFrame("Frame")
local defaults = {
TotalXP = 0
}
Congrats_EventFrame:RegisterEvent("ADDON_LOADED")
Congrats_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN")
Congrats_EventFrame:SetScript("OnEvent",
function(self, event, ...)
if event == "CHAT_MSG_COMBAT_XP_GAIN" then
-- do stuff
elseif event == "ADDON_LOADED" then
local addon = ...
if addon == "XPlogger" then
XPLogger = XPLogger or defaults
self:UnregisterEvent(event)
end
end
end)