Can't get return value from a function

I don’t know why I can’t get the value from the function, can anyone help me?

Client:
function Test()
ESX.TriggerServerCallback(‘Test’, function(value)

    print(value) <-- This line can print 'abc'

    return value
end)

end

print(Test()) ← But this line print nothing or ’ ’

Server:
ESX.RegisterServerCallback(‘Test’, function(source, cb)
cb(‘abc’)
end)

Next time, do try to properly use formatted text. Thing that you sent here is a pain to read. Anyway.

You got one thing wrong, you are returning an function, but not the one you want.
For now(I’ll use C# name), function you are calling is void. It does not return anything.
You know why? Because ESX.TriggerServerCallback uses function as its second parameter.

To properly return given callback try this, use Citizen.CreateThread or CreateThread to call the function.

function Test()
    local retval
    ESX.TriggerServerCallback('Test', function(value)
        retval = value
    end)
    while not retval do
        Citizen.Wait(10)
    end
    return retval
end

Citizen.CreateThread(function()
    print(Test())
end)

This example here will return callback value as soon as its available. You must be aware that until value is returned, Thread won’t be executed further until function has returned.

better and simple way to do it

function Test()
    local callback = promise:new()
    ESX.TriggerServerCallback('Test', function(value)
        callback:resolve(value)
    end)
    return Citizen.Await(callback)
end

Citizen.CreateThread(function()
    print(Test())
end)

You’ve removed 3 lines of code and replaced values with other types of functions. If It works the nothing stops anyone from using it. But goodluck to new people down there trying to understand it. (I’m not against using other ways to achieve the same result, but there is a major difference between the first and second example. Second not so simple, at least in way of explaining to some major beginner.)