# Fix an attempt to index a nil value

An “attempt to index a nil value” message identifies the file and line where Lua received no table
or object. Fix the first error in the log before changing downstream resources.

## Evidence to collect

- Full first stack trace, not only its final line
- Resource name, deployed commit, and local diff
- Whether the code runs on client or server
- Values immediately before the failing access

## Diagnostic

For `Player.PlayerData.job.name`, Lua can fail because `Player`, `PlayerData`, `job`, or `name` is
missing. Log the boundary value without printing tokens or private player data:

```lua
local Player = QBCore.Functions.GetPlayer(source)
if not Player then
    print(('missing player object for source %s'):format(source))
    return
end
```

Common causes are code running before `OnPlayerLoaded`, an invalid server `source`, a callback that
returned `nil`, a resource that started before its dependency, or a key that changed between
commits. Confirm the current export or callback signature at the deployed source.

## Fix and verify

Fix the lifecycle or data contract that produced `nil`. Add a guard only when absence is an expected
state. Reproduce the original flow, reconnect once, restart the affected resource, and confirm the
first error does not return.

## Rollback

Restore the previous resource commit and configuration. Keep the failing logs and diff so the data
contract can be corrected before retrying the update.

## Sources

- [qb-core client lifecycle events](https://github.com/qbcore-fivem/qb-core/blob/9b3cddcce93e5e12cbcf6b47b866b687d32ac7bf/client/events.lua)
- [qb-core player lookup functions](https://github.com/qbcore-fivem/qb-core/blob/9b3cddcce93e5e12cbcf6b47b866b687d32ac7bf/server/functions.lua)
