NexthostingLogs

Logs / Error guide / FiveM

FiveM: “SCRIPT ERROR: @resource/…”

What the message means

A script in a resource stopped with an error. After the @ comes the name of the resource, then the file and line. The lines with “>” below show where the script was called from.

What it looks like in the log

[ c-scripting-core] Creating script environments for esx_policejob
[ resources] Started resource esx_policejob
[ script:esx_policejob] SCRIPT ERROR: @esx_policejob/server/main.lua:112: attempt to index a nil value (field 'job')
[ script:esx_policejob] > handler (@esx_policejob/server/main.lua:112)
[ script:esx_policejob] > Citizen.CreateThread (@es_extended/imports.lua:35)

Excerpt from an example log, marked the way the analysis marks it.

Common causes

  • “attempt to index a nil value”: a value is missing – often player data that isn't loaded yet, or a job that doesn't exist.
  • The resource starts before its dependency (order in server.cfg).
  • The script is for a different framework or a different framework version (ESX Legacy, old ESX version, QBCore).
  • A database entry is missing because the resource's SQL file wasn't imported.
  • Faulty entries in the resource's config.lua.

How to fix it

  1. Read the name after the @ – that's the resource. The analysis groups all errors of a resource.
  2. In server.cfg, check that the framework (es_extended, qb-core), database (oxmysql) and libraries (ox_lib) start before the resource.
  3. Import the resource's SQL file, if it ships one.
  4. Check whether the resource matches your framework version, and update it if needed.
  5. Restart the resource with restart <name> and watch whether the error comes back.