Attempt to index a nil value (global 'QBCore')

Hello so first of im learning i have searched forums to try and resolve this issue but nothing seems to be helping.

Im using the FrameWork QBCore and im running the script and it keeps giving me the error attempt to index a nil value (global ‘QBCore’) i fell this would be quite a easy fix but im unsure so if someone could help it would be great

this is my code which to me everything seams fine
i can post the error from the console aswell
Desktop Screenshot 2021.12.16 - 20.26.05.12 (2)

4 Likes

Hey :slight_smile: !
I’m not really familiar with QBcore yet, but when I check the code of multiple of the QBcore scripts I have on my QBtest server they don’t initialize the QBcore object the same way as you do. The way you are doing it looks more like the ESX way.

Here is what I got on my side :

local QBCore = exports['qb-core']:GetCoreObject()
10 Likes

ill try that

3 Likes

this would replace line 4 correct?

1 Like

this sorted it thank you so much

2 Likes

No probs :wink:

1 Like

QBCore is not backwards compatible with itself so you will need to stay up to date with their latest changes so I would recommend just joining their discord

This my error message and code. If any one could help me would mean alot. Thank you x


1 Like

Hey :slightly_smiling_face: !

Doing the same thing I was talking about in my messages above should fix it.
Add the following at the top of your ‘client/main.lua’ :

local QBCore = exports['qb-core']:GetCoreObject()
2 Likes

Thank you so so much! it fixed. s

hey this didnt work for me

1 Like

Hey :slightly_smiling_face:
Could you give us a little more details (what action make the error pop up, screen of the console with the error and the code of the scripts that generate the error)

1 Like

1 Like

Hum… Check in your ‘server.cfg’ if the order in which you start resource is good (and that you put your resources in the right folder ([qb]) :
screen114

You could try to add the following to the ‘fxmanifest.lua’ of the scripts that are genereting errors (instead of using the method I shared at the beginning) :
screen115



Try to add the line I sent you in your ‘_resource.lua’ (you add the QBcore imports as a shared script)

OK I will try that when I wake back up

Yup that was a no go still not working

Try changing functions to QBCore if you are on the latest core.

Hi thank you for the response how do I change functions like that