This is the second time I ask this question, but I will explain it better as no one understood what I was looking for.
So, let’s say I want a client script to find a value from a server script and bring it back to the client script. The way I’ve been doing this is as follows:
-- Declare the variable (without the actual value) value = nil -- Start the value retrieval process TriggerServerEvent("test:find") -- New event to bring the value to this file from the server (called from the server, of course) RegisterNetEvent("test:bring") AddEventHandler("test:bring", function(newvalue) value = newvalue end)
-- The value I want the client to retrieve value = 10 -- Event that starts the whole process (called from the client) RegisterServerEvent("test:find") AddEventHandler("test:find", function() -- Finally send the value to the client! TriggerClientEvent("test:bring", value) end)
So this is the absolutely annoying way I use to retrieve a value from server to client or viceversa. There must be a damn easier way to do this.
Any idea is appreciated.