Using a QB script, getting attempt to index a nil value

Let me say first off, that I am learning, obviously. I have searched forums for a fix/answer but I feel it’s that I don’t quite know how to ask how to fix X (the problem), so I keep searching for fixes for Y (the symptom). Appreciate any and all help.

Using a custom framework (LLRP) someone put together. It is a modified QB-Core frame. I am trying to add the QB-Traphouse script to the city.

When I start it, I get this error: attempt to index a nil value (global ‘LLRP’)

The line it is pointing me to is: if LLRP.Functions.GetPlayerData() ~= nil then

It is a portion of this: Citizen.CreateThread(function()
Wait(1000)
if LLRP.Functions.GetPlayerData() ~= nil then
isLoggedIn = true
PlayerData = LLRP.Functions.GetPlayerData()
LLRP.Functions.TriggerCallback(‘qb-traphouse:server:GetTraphousesData’, function(trappies)
Config.TrapHouses = trappies
end)
end
end)

Almost everything I am seeing online is in regards to ESX and none of the fixes seemed to work. I know I am missing something here. Any care to point me in the right direction? Lemme know what info you need. Thanks!

Just has to do with importing your core to the script, there are multiple ways to do it but you just have to use one (or rather should otherwise you will be getting the core is nil error again). Guesing this is an old Framework so in most of the other script there should be a while loop with LLRP == nil get object … . You should also add that to your traphouse script both on the client and server sided file. For the other methods you could always refer to the QBCore Framework community and ask for further help there: QBCore Framework

Thanks for the reply. Comparing some of my working scripts to this one, am I going in the right direction adding this before it?

LLRP = nil

Citizen.CreateThread(function()

while true do

    Citizen.Wait(1)

    if LLRP == nil then

       

        TriggerEvent("LLRP:GetObject", function(obj) LLRP = obj end)    

        Citizen.Wait(200)

    end

end

end)

Sry, maybe this? Other one doesn’t seem to work either. No error but no function, either.

Citizen.CreateThread(function()

while LLRP == nil do

    TriggerEvent('LLRP:GetObject', function(obj) LLRP = obj end)

    Citizen.Wait(0)

end

end)

1 Like

Yea should’ve been the first one (even though it didn’t work). And the server side one is just 2 lines.

1 Like

I loathe to ask because I’m sure it’s something obvious, can you clarify what you mean by the server side on being just 2 lines? Thanks much, been trying different things for hours

I figured it out, I’m sorry!

It was:
LLRP = nil

TriggerEvent(‘LLRP:GetObject’, function(obj) LLRP = obj end)

Knew it was something silly I was missing. Thanks so much for you help. Now I just gotta figure out how this script works lol

Yes that is it sir, so the script starts up now and runs? Traphouse really isn’t that difficult to understand. If you need a replacement for the money laundering part you can always use one of mine script x). [PAID] [QB] Money Laundering

Not quite. I think my issue, and issues I’ve had with other QB scripts is this custom frame, as you said, is older or something. I am discovering that these files are looking for an @qb-core/import.lua file. I don’t seem to see an import.lua in my custom frame, nor the QBCore latest release. Is there some way around this?

Appreciate you helping an unknowledgeable peon.

Well like I said:

If you want the import.lua method than you just need to add this this in your core. As you can see it is in the latest QBCore version x). Of course rename everything to your Core name and voila. And in the manifest file there should be a @qb-core/import.lua line somewhere like you said.