Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
attempt to call a nil value (upvalue 'successCB')

Hello i have a problem and it says attempt to call a nil value (upvalue 'successCB') i have tried different methods but didn't work so i want to know if you guys could help me

Here is the a picture of error

and here is main.lua:20

RegisterNUICallback("main", function(data)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    successCb()
end)

below also is a short part of the code JS code

    $("#submit").click(function () {
        let inputValue = $("#input").val()
        if (inputValue.length > 4) {
            $.post("http://vny-lvaultcodes/error", JSON.stringify({
                error: "Code cannot be greater than 4"
            }))
            $("#container").fadeOut(250);
            return
        } else if (!inputValue) {
            $.post("http://vny-lvaultcodes/error", JSON.stringify({
                error: "You need to type a 4 digit code for submitting."
            }))
            $("#container").fadeOut(250);
            return
        }
        if(inputValue == code){
            $.post('http://vny-lvaultcodes/main', JSON.stringify({text: inputValue,}));
            $("#container").fadeOut(250);
        } else {
            $.post('http://vny-lvaultcodes/failed', JSON.stringify({}));
            $("#container").fadeOut(250);


        }

also below it is a function to open the ui and stuff

function openCode(show, code, success, fail)
    successCb = success
    failCb = fail
    display = true
    SetNuiFocus(true, true)
    SendNUIMessage({
        type = "open",
        code = code,
    })
end
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

I'm unfamiliar with fivem but looking at the documentation, I think you've defined your callback incorrectly.

https://docs.fivem.net/docs/scripting-manual/nui-development/nui-callbacks/

RegisterNUICallback not only takes a data value but the callback as well (cb in the document).

In your case successCb would be nil thus when you call successCb() it produces the error.

As such, I'd try one of the following:

RegisterNUICallback("main", function(data, successCb)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    successCb()
end)
RegisterNUICallback("main", function(data, cb)
    SetNuiFocus(false, false)
    QBCore.Functions.Notify("Authorization Success" , 'success', 7500)
    cb()
end)

Hopefully that helps.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!