RexZenn Docs Back to site

FiveM errors FAQ

Quick answers for the errors you hit most while developing FiveM resources.

On this page

Click a question to open the answer. Server errors show in the server console (or txAdmin's live console). Client errors show in the in-game console, opened with F8.

Reading errors#

How do I read a SCRIPT ERROR line?

A typical one looks like this:

Console
SCRIPT ERROR: @my-resource/server.lua:14: attempt to index a nil value (local 'player')

It tells you three things: the resource (my-resource), the file and line (server.lua, line 14), and what went wrong. Open that file at that line, then look at the lines above it to see where the broken value came from.

"attempt to index a nil value" or "attempt to call a nil value"

Index a nil value means you used something like player.name while player was empty. Call a nil value means you ran a function that doesn't exist, like DoThing() when nothing with that name is defined.

Common causes: a typo, the data hasn't loaded yet, the player left, a function is defined further down the file, or you used a client-only function on the server.

Print the value just before the error, and guard against empty values:

server.lua
local ped = GetPlayerPed(source)
if not ped or ped == 0 then return end
"unexpected symbol near" or "Failed to load script"

That's a syntax error. The line number is where Lua noticed the problem, so the real mistake is often on the line before. The usual suspects are a missing end, then or do, a missing comma in a table, or an unclosed quote. A Lua extension in VS Code underlines these while you type.

Resources won't start#

"Couldn't find resource my-resource"
  • The name in ensure must match the folder name exactly, including capitals.
  • The folder must be inside resources (it can sit inside a [category] folder).
  • Run refresh in the console after adding a new folder.
  • If you downloaded it from GitHub, rename folders ending in -main or -master.
"No resource manifest" or it can't find fxmanifest.lua

fxmanifest.lua has to be directly inside the resource folder. Unzipping often creates a folder inside a folder, so move the inner one out. A minimal manifest looks like this:

fxmanifest.lua
fx_version 'cerulean'
game 'gta5'
lua54 'yes'

client_script 'client.lua'
server_script 'server.lua'
I changed my code but nothing changed in game

Run restart resource-name in the console. If you added or renamed files, run refresh first so the manifest is re-read. Edits to server.cfg only apply after a full server restart. For client scripts, check F8 after the restart in case the new version has an error.

"No such export" or a resource fails because a dependency is missing

The resource providing the export hasn't started yet. Order in server.cfg matters, so ensure the dependency above anything that uses it. You can also list it in the manifest so it starts first:

fxmanifest.lua
dependency 'oxmysql'

Also check the export name for typos and that the other resource actually defines it.

Connecting and networking#

"Could not bind" or "address already in use" on port 30120

Another copy of the server is still running, often in the background. Find and stop it:

PowerShell
netstat -ano | findstr :30120
taskkill /PID 1234 /F

Replace 1234 with the number at the end of the matching line.

Friends get "connection timed out" but I can join

Work down this list:

  1. Port 30120 is forwarded for both TCP and UDP to the server PC's current address.
  2. The Windows Firewall rules exist (see the home server guide).
  3. The server PC's local address hasn't changed since you set the rule.
  4. Your router's WAN IP matches your public IP. If it doesn't, your ISP uses CGNAT and port forwarding won't work.
  5. Your friend is using your public IP or DuckDNS name, not 192.168.x.x.
"Failed to verify license key" or the key is invalid

Copy the key again from the Cfx.re Portal and check sv_licenseKey "..." in server.cfg for extra spaces or missing quotes. Make sure the key wasn't revoked, and that you aren't running two servers on the same key. If you use txAdmin, you can re-enter the key in its settings.

The server says it's outdated, or clients can't join

Download the newest recommended server build and extract it over your server folder (never over server-data). Keep your game client updated too.

Server-side player functions don't work (OneSync)

Some natives only work on the server when OneSync is on. Add this to server.cfg and restart the server:

server.cfg
set onesync on

Scripts and performance#

"server thread hitch warning"

Something blocked the server for too long. The usual causes are a heavy loop, a slow database query, or a resource doing too much work in one go. Find the culprit by stopping resources one at a time until the warnings stop, then look at what that resource does on a timer or on player join.

My resource uses too much CPU time

In the F8 console, type resmon 1 to see how many milliseconds each resource uses per frame. Loops that run Wait(0) forever are the most common cause. Only run every frame while the player is actually close to something:

client.lua
CreateThread(function()
  while true do
    local sleep = 1000
    local pos = GetEntityCoords(PlayerPedId())

    if #(pos - vec3(215.0, -810.0, 30.7)) < 10.0 then
      sleep = 0
      -- draw the marker and check for the key press here
    end

    Wait(sleep)
  end
end)
How do I debug a script?
  • Use print() to see values. Server prints show in the server console, client prints in F8.
  • Print the value that was nil, not just a message saying you reached the line.
  • For web interfaces (NUI), run nui_devtools in F8 to open the browser developer tools.
  • Use resmon 1 to find resources that are slow.

Database#

oxmysql errors like "ECONNREFUSED" or "Access denied"

Check the connection string in server.cfg:

server.cfg
set mysql_connection_string "mysql://user:password@localhost/database"
  • ECONNREFUSED: the database server isn't running, or the port is wrong.
  • ER_ACCESS_DENIED_ERROR: wrong username or password.
  • ER_BAD_DB_ERROR: the database name doesn't exist yet. Create it first.

Special characters in the password must be URL-encoded, or just use a simpler password.

Game client#

FiveM gets stuck loading, crashes, or shows odd errors

Close FiveM and delete the cached server files. In File Explorer, open %localappdata%\FiveM\FiveM.app\data and delete the folders named server-cache and server-cache-priv. Start FiveM again and reconnect. If it still crashes, update your graphics driver and check that GTA V itself is up to date.

Still stuck? Copy the exact error text and the file name and line number, since those are what anyone helping you will ask for first.