[Edited]
01 | local scriptService = game:GetService( "ScriptContext" ) |
02 | local ds = game:GetService( "DataStoreService" ) |
03 | local errorLogs = ds:GetOrderedDataStore( "ErrorLogs" ) |
04 |
05 | local function errorDetected(message,trace,brokenScript) |
06 | print ( "Error detected: " .. tostring (message)) |
07 | local key = tostring (math.floor(os.time())) |
08 | pcall ( function () errorLogs:UpdateAsync(key, function () return { Script = brokenScript:GetFullName(),Error = message,Trace = trace } end ) end ) |
09 | end |
10 |
11 | game.Workspace.RemoteFunction.OnServerInvoke = function (...) errorDetected( select ( 2 ,...)) end |
12 | scriptService.Error:connect(errorDetected) |
Look at dat efficiency :p
error
is a built-in function that acts similar to print
except also causing an error and stopping execution.
You cannot save functions in data stores.
Most likely you meant to use message
instead.