Simple question: Function parameters

Hey everyone, I have a pretty simple question for you all. I’m confused on whether certain functions send parameters or recieve parameters, and I’m having trouble differentiating between the two. For example:

local localVariable = 5
TriggerClientEvent("clientEvent", localVariable) -- obviously, in this case, localVariable is sent to the client script.
RegisterNetEvent("clientEvent")
AddEventHandler("clientEvent", function(localVariable)) -- and localVariable is received here, right?

My question is, how am I supposed to know if a function is sending or recieving a variable? This case in particular doesn’t do my question justice as it’s pretty simple, but in other cases, my question applies.

And does it matter what the the variable name in the function that is recieving it is? For example:

RegisterNetEvent("clientEvent")
AddEventHandler("clientEvent", function(notNamedLocalVariable)) -- will this take the value of localVaraible?

I know this isn’t a question regarding FiveM in particular, and is more of a simple programming question, but I was hoping someone may be able to explain this to me. Thanks!

Yes that notNamedLocalVariable will “get” the value passed to that event. So in this case it’ll get the value from the “localVariable” variable because you passed that as an argument when calling/triggering the event.

Take a look at the following example script:

local varA = "A"
TriggerEvent("some_event_name", varA) -- (This sends varA ("A") as a parameter)

-- Somewhere else in the code:
AddEventHandler("some_event_name", function(varB)
    print(varB) -- This will print "A" to the console.
    -- Because varB can be called anything, it will always have the value that
    -- was passed in as the 1st argument when calling this event
    -- In this case: [ TriggerEvent("some_event_name", varA) ] it will get the
    -- value of "varA" ("A").
end)

I see. Thank you for your reply!