function logMessage (TheMessage) year = tonumber(os.date("%Y")); month = tonumber(os.date("%m")); day = tonumber(os.date("%d")); hour = tonumber(os.date("%H")); minutes = tonumber(os.date("%M")); seconds = tonumber(os.date("%S")); if (string.len(month) == 1) then month = "0" .. month end if (string.len(day) == 1) then day = "0" .. day end if (string.len(hour) == 1) then hour = "0" .. hour end if (string.len(minutes) == 1) then minutes = "0" .. minutes end if (string.len(seconds) == 1) then seconds = "0" .. seconds end logtime = year .. month .. day .. " " .. hour .. minutes .. seconds file = io.open("mylog.txt", "a") file:write(logtime .. " " .. TheMessage.."\n") file:close() end