Systematic debugging for production resources
Something will break. That is not a maybe, it is a certainty. The difference between a beginner and a developer is not that the developer writes perfect code. The difference is that the developer knows how to read the error, find the line, diagnose the category, and fix it calmly instead of changing code at random. This lesson teaches you that skill.
Build it
Make the resource folder
Inside your server's resources folder, create this folder:
resources/qu_debugging_like_a_developer
Create the files
Create this exact file layout:
resources/qu_debugging_like_a_developer/
fxmanifest.lua
client.lua
Write fxmanifest.lua
Open fxmanifest.lua and paste this:
fx_version 'cerulean'
game 'gta5'
client_script 'client.lua'
Older tutorials add a lua54 'yes' line here. As of June 2025 that setting is deprecated and ignored: Lua 5.4 is now the only Lua runtime, so you leave it out.
Write the lesson code
Open client.lua and paste this:
local function log(message)
print('[qu_debugging_like_a_developer] ' .. message)
end
local function risky()
error('planned failure')
end
RegisterCommand('debugfail', function()
local ok, result = pcall(risky)
if ok then
log('risky() succeeded, returned: ' .. tostring(result))
else
log('risky() failed, error was: ' .. tostring(result))
log(debug.traceback('stack at point of failure', 2))
end
end, false)
Start and test it
Open server.cfg and add this line:
ensure qu_debugging_like_a_developer
Save. Because this folder is brand new, the running server does not know it exists yet, so run these two lines in the txAdmin Live Console, one at a time:
refresh
ensure qu_debugging_like_a_developer
refresh rescans the resources folder so the server discovers your new folder. ensure then starts it (and on later edits, ensure restarts it). Use restart qu_debugging_like_a_developer only after the resource has already been started once in this session.
Now join the server, press F8 to open the in-game console, and run the test there:
/debugfail
Because this is a client_script, the print lands in F8, not in txAdmin. You will see two lines:
The exact line number after client.lua: will match wherever the error(...) call sits in your file. In the code above that is line 6.
Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- How it works
- If something went wrong
- What you can do now
- Try it yourself
The remainder of Systematic debugging for production resources is available to FiveM School members.