FiveM Events Explained: TriggerEvent and RegisterNetEvent
How FiveM events work, when to use TriggerEvent, TriggerServerEvent and TriggerClientEvent, and why RegisterNetEvent is needed for network events.
Short answer
An event is a named message that one part of a script sends and another part listens for. TriggerEvent runs handlers on the same side, either the client or the server. To cross between them, use TriggerServerEvent from the client to reach the server, or TriggerClientEvent from the server to reach clients. In Lua, the receiving side must also mark the name as network-safe with RegisterNetEvent.
Local vs network events
Events come in two kinds. Local events stay on one side. AddEventHandler listens for them, and the Cfx security guide notes that it handles events within the same context, client to client or server to server, and is not networked. Network events cross the boundary between client and server. RegisterNetEvent marks an event as safe for network use, so a server script can trigger it on the client, or a client script can trigger it on the server.
The common functions
TriggerEvent and AddEventHandler handle local events. Both calls below must run on the same side:
-- Both lines live in the same script, on the same side
AddEventHandler('myresource:localEvent', function(value)
print(value)
end)
TriggerEvent('myresource:localEvent', 'placeholder value')
The Cfx docs describe TriggerEvent as the function for local events, used within the same side of a script.
Client to server
A client script calls TriggerServerEvent to send an event to the server. The server listens with RegisterNetEvent. On the server, the global source holds the ID of the player who sent the event.
-- client.lua
TriggerServerEvent('myresource:requestSomething', 'placeholder value')
-- server.lua
RegisterNetEvent('myresource:requestSomething', function(value)
local src = source
print(('Player %s sent a value'):format(src))
end)
The listening-for-events guide warns that source is only guaranteed to be valid during the first call. Copy it to a local variable, as shown, if you need it later or in async code.
Server to client
The server calls TriggerClientEvent with the event name, a target, and any data to send. The target is a player ID, or -1 to reach every connected client. The client listens with RegisterNetEvent.
-- server.lua
TriggerClientEvent('myresource:showMessage', -1, 'placeholder text')
-- client.lua
RegisterNetEvent('myresource:showMessage', function(text)
print(text)
end)
Validating data from a client
Treat every value a client sends as untrusted. The Cfx security guide says cheats can trigger events from any context, so client-side checks are not enough. Check data again in the server handler and look up sensitive values, such as money, inventory, position, or permissions, on the server.
RegisterNetEvent('myresource:requestSomething', function(value)
local src = source
if type(value) ~= 'string' or #value > 64 then
return
end
-- check permissions and state on the server before acting
end)
Common mistakes
- Wrong event name. Event names are plain strings. The trigger and the handler must match exactly, including any prefix you use.
- Registering after use. A handler added after an event has fired cannot receive that call. Register handlers when the script loads.
- Using TriggerEvent across the network.
TriggerEventstays on the same side. UseTriggerServerEventorTriggerClientEventto reach the other side. - Trusting client data. The security guide says a client can send any event with any values, so validate on the server.
FAQ
Do I always need RegisterNetEvent?
In Lua, yes, for any event that must work over the network. The RegisterNetEvent reference says it marks an event safe for network use. The Cfx docs note that C# does not need this step.
Can a client use TriggerEvent to reach the server?
No. TriggerEvent runs handlers on the same side. A client sends to the server with TriggerServerEvent.
What does -1 mean in TriggerClientEvent?
It targets every connected client. A specific player ID sends the event to that one client only.
Sources
- Triggering Events (Cfx docs)
- Listening for Events (Cfx docs)
- RegisterNetEvent (Cfx docs)
- TriggerClientEvent (Cfx docs)
- Secure Your Events (Cfx docs)
Last checked: 29 November 2026
Not confirmed: I did not open the AddEventHandler, TriggerEvent, or TriggerServerEvent reference pages directly. Their behavior here comes from the guides above. I did not run the examples on a live server.
FiveM.tools was founded with sponsorship from Nyru.