Catch/Detect script error from console or client console (F8)

Our server has some script errors that we see over our head since we don’t stalk the console or client console (aka F8)

And, when players dont notice that something inst working correctly, they woulnd’t press F8 to check if there was an errror, right?

So i was thinking about a discordwebhook that sends a message when a script error is found.
But after some searching i couldn’t really find anything that ‘detects’ if there was an script error, and from what script it came… This would make our lifes 100 times easier, because we know most likely always when a script error was found and needs to be fixed.

So, if anyone has any idea how to detect if there was an script error and send it to a discordwebhook please let me know! (The discordwebhook is already working, but im just tackling with detecting if a script error was found)

I am pretty sure that there an way to detect it since FiveM pretty much prints it in the client console (aka F8), but i can’t really find how they did that…

Thnx,

if you found any solution pls tell me thnx.

Don’t know if this helps but you could try overwriting the xpcall function:

local OLD_XPCALL<const> = xpcall

xpcall = function(f, err, ...)
	local status, error, retval = OLD_XPCALL(f, err, ...)
	print(string.format("Script threw this error: %s", error))
end

However this needs to be done in every Lua RE for every resources :confused: