This...
...does nothing. It declares a local variable named "Screenshot" within that function, that's it.
You also can only do one SetScript of each kind for each frame object. The second time you declare the "OnEvent" will replace the first one. You're also missing a quote right before Congratulations, I'm surprised you didn't get an error for that.
This will do what you want:
Lua Code:
local Congrats_EventFrame = CreateFrame("Frame")
Congrats_EventFrame:RegisterEvent("PLAYER_LEVEL_UP")
Congrats_EventFrame:SetScript("OnEvent", function(self, event, arg1, arg2, arg3)
if event=="PLAYER_LEVEL_UP" then
print("Congratulations on reaching level "..arg1..", "..UnitName("Player").."! You gained "..arg2.." HP and "..arg3.." MP!")
Screenshot()
end
end)