Find the missing object
The first step is not to rewrite the resource. It is to find the value that became nil. Look at the line in the error and identify the object before the dot, colon or bracket. If the line reads Player.PlayerData.job.name, then Player, PlayerData or job could be missing. Check each layer separately. This keeps the fix small and stops you from hiding the error without solving the cause.
Copy the full error, not just the words nil value. The file path and line number matter. Lua errors often point to where the script finally failed, while the missing value may have been created earlier or never created at all. Inspect the few lines above the error and any callback or event that feeds the value.
Check the core object
If QBCore itself is nil, check startup order and export style. The custom resource must start after qb-core. Older scripts may use a core access pattern from a different QBCore version. Verify your installed framework before replacing lots of code. A quick temporary print can prove whether the resource can see the core object, but the final patch should keep clean validation instead of noisy debug output.
local QBCore = exports['qb-core']:GetCoreObject()
if not QBCore then return endValidate player data timing
PlayerData can be empty until the character has fully loaded. Client scripts that run too early often read job, gang or metadata before it exists. Server scripts can also fail if the player has disconnected or if the source value is invalid. Wait for the proper loaded event, or fetch the player object at the moment of the action and check it before reading nested fields.
Inspect config tables carefully
Config mistakes are one of the most common causes. A job name, item name, grade, stash id, coordinate table, locale key or feature toggle can be misspelled. The script then tries to read a table entry that does not exist. Search for the exact key across config, client and server files. Confirm each parent table exists before checking the final property.
Handle database and callback failures
Callbacks and database queries can return nothing. That can happen when the row is missing, the query fails, the dependency is not ready or the player does not meet the conditions. Treat results as optional until verified. If no row is found, return cleanly with a helpful warning instead of indexing deeper into missing data. This makes the next error much easier to understand.
Keep the fix narrow
A good patch names the nil value, explains why it was nil and changes the smallest piece of code needed. It may add a guard, fix start order, correct a config key or move logic after player load. Avoid broad rewrites that change unrelated systems. They make testing harder and can add new bugs.
Test both success and failure paths
After fixing the nil value, test the normal action and the denied action. Use one player, one job, one item and one command first. Then test a player without permission, an invalid item, an empty database row and a reconnect. If the script touches money or inventory, keep trusted checks on the server.
What to paste into Stellar AI
Provide the exact error, the surrounding code, the config table, the framework version, the start order and what action caused the problem. Ask for diagnosis first. The best answer should point to the missing value and show a small, testable fix.
Fix the nil value cleanly
Paste the evidence into Stellar AI and ask for a minimal patch. Test privately before using the fixed resource live.
Open Stellar AI free →