Frameworkcrash
attempt to index a nil value (field 'job')
Also seen as: attempt to index a nil value (field 'job') PlayerData.job nil job name nil ESX QBCore ESX.GetPlayerData job nil
What causes it
You read PlayerData.job (or .job.name) before the player's data finished loading. On first join the framework populates job asynchronously, so early code sees job as nil. Restarting the script in-game 'fixes' it only because you're already loaded by then — a classic timing bug.
How to fix it
Wait for the player to be fully loaded before reading job, and guard the access.
- Don't read PlayerData.job at the top level or immediately on resource start.
- QBCore: wait for the
QBCore:Client:OnPlayerLoadedevent, then read job; keep it updated viaQBCore:Client:OnJobUpdate/OnPlayerUpdated. - ESX: after getSharedObject, loop
while ESX.GetPlayerData().job == nil do Wait(10) end, or handleesx:playerLoadedandesx:setJob. - Guard access:
if PlayerData.job and PlayerData.job.name then ... end. - On resource restart, re-fetch: in
onResourceStartfor your own resource, call GetPlayerData() again.
Related errors
Related guides
Still stuck? We can help.
Viper Multi-Job lets players hold several jobs and switch between them with grade, salary and duty handled — QBCore, QBox and ESX, validated server-side.