I'm not sure what is causing the event to fail, but instead of using a ton of if statements to format the hours, minutes and seconds with a leading zero, something like this should probably do:
local lottery = string.format("%02d:%02d:%02d", hours, minutes, second)
Another thing you could do...