[Edited]
local scriptService = game:GetService("ScriptContext") local ds = game:GetService("DataStoreService") local errorLogs = ds:GetOrderedDataStore("ErrorLogs") local function errorDetected(message,trace,brokenScript) print("Error detected: "..tostring(message)) local key = tostring(math.floor(os.time())) pcall(function() errorLogs:UpdateAsync(key, function() return {Script = brokenScript:GetFullName(),Error = message,Trace = trace} end) end) end game.Workspace.RemoteFunction.OnServerInvoke = function(...) errorDetected(select(2,...)) end 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.