How to get data returned from an event?

Hi, I have been trying this in several ways but I don’t really know how can I get data returned from an event

e.g.:

–In a server.lua file:

RegisterNetEvent(“test_event”)
AddEventHandler(“test_event”, function()
–The code goes here, the output variable will be test wich contains an string
return test
end)

–In another client.lua file:

RegisterCommand(“test_command”, function(source, args)
local test = TriggerServerEvent(“test_event”)
print(test)
end)

The Output should be the same string, I think. But instead, it returns an integer.

Any solution for this? Or isn’t there any way to get data returned from an event.

Thanks in advance, Jose Manuel.

Wait, what. I’m pretty sure events can’t “return” variables, not like that. Where does test come from? What do you want to do?

Is an example, I want to get a variable from the event returned. To be able to use it in a client side script.

Soooo…like this?

--[[ SERVER ]]--
count = 0

RegisterNetEvent('sv.CountOne')

AddEventHandler('sv.CountOne', function()
    count = count + 1
end)

--[[ CLIENT ]]--
TriggerServerEvent('sv.CountOne')

Similar but not like that, I want to pass a variable, integer or string from an executed event to the part where it was executed. Something similar to what would do return. Because I want the event to be in a different file from where it was triggered.

oh…oOHHH I see what you mean now.

Use a callback resource, like this one: [RELEASE] Lua Callback system

ohh thx that was what I was serching for