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!
PotatoPC · 8/25/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.
ToxicGamer · 8/25/2026
Sign in to reply.
@rafi is right on the timing issue. The problem isn't with your export call - that's working fine. The issue is that QBCore's player data isn't populated yet when your resource first loads during a fresh join. Your file scope code runs immediately when the resource starts, but the framework's player-loaded event hasn't fired at that point.
The empty table confirms your resource is reading the framework state before QBCore has finished setting up the player session. This is different from a resource restart where the player is already fully loaded into the framework, so the data exists when your code runs again.
You'll need to wait for QBCore's player-loaded event before accessing the job data, or structure your code to handle the case where PlayerData is still empty.
ChillGuy · 8/26/2026
Just tested what @rafi suggested - added the log to see what's in PlayerData at file scope. On a fresh join it's definitely an empty table {}. The weird thing is that even though it's empty, there's no server error thrown, which makes it harder to catch.
So @nina is right about the timing - during a fresh join the framework hasn't populated anything yet, but on a restart the player is already loaded. Still not sure how to properly handle this since I need the job data right away for my resource to work.
PotatoPC · 8/28/2026