Hey everyone, I'm having an issue with getting player data in a QBCore client resource. When my resource loads on a fresh join, PlayerData.job comes back as nil, but if I manually restart the resource after joining, it works fine.
I'm trying to access the player's job right at the start of my client file:
local QBCore = exports['qb-core']:GetCoreObject()
local PlayerData = QBCore.Functions.GetPlayerData()
print(PlayerData.job.name)On a fresh join this throws an error because PlayerData.job is nil, but if I do /refresh on my resource after joining, then it works and prints the job name correctly. The weird thing is there's no server error - just the client-side print showing an empty table initially.
Is there some kind of timing issue where the player data isn't loaded yet when the resource first starts? How do I handle this properly so it works both on fresh joins AND after resource restarts?
Thanks!
Leo · 25/08/2026
This looks like you're hitting a timing issue where your resource is trying to access player data before it's fully available. The fact that it works after a manual restart but fails on fresh join suggests the data isn't ready when your file scope code runs initially.
Can you add a log to show exactly what PlayerData contains at file scope during a fresh join? Something like print('File scope PlayerData:', json.encode(PlayerData)). I want to confirm whether you're getting an empty table {} or if it has some fields populated but missing the job specifically.
Rafi · 25/08/2026
Sign in to reply.