Client vs Server Scripts in FiveM Lua
Client scripts run in each player's game, server scripts run on the server, and events are the only way they share data. Learn what runs where.
Short answer: in FiveM Lua, client scripts run on each player's own game, and server scripts run on the server. The two sides do not share variables. The way they pass data to each other is through events.
Short answer
Client scripts run on each player's game. Server scripts run on the server. A client script cannot read a variable from a server script, and a server script cannot read a variable from a client script. To move data from one side to the other, send it in an event.
The two sides
Client scripts run on each connected player's game. The FiveM scripting manual describes most gameplay work as done in client scripts. Each player has their own copy.
Server scripts run on the server. The manual describes them as the place for actions that involve several clients, and as a trusted place for things such as storing data. Rules that every player must follow belong here.
What runs where
| Task | Where it usually belongs | Why |
|---|---|---|
| Reading the player's own input, such as a key press | Client | The input happens on that player's game |
| Drawing on the player's screen | Client | Only that player's game shows it |
| Checking money, jobs or permissions | Server | Players must not decide these themselves |
| Saving data to a database | Server | The server is the trusted, shared side |
| Sending a message to one or all players | Server, with TriggerClientEvent | TriggerClientEvent sends from the server to clients |
fxmanifest entries
The manifest tells FiveM which files belong to each side. See fxmanifest.lua explained for the full file.
client_scriptsloads files on the client.server_scriptsloads files on the server only.shared_scriptsloads files on both.
The reference also documents the singular forms client_script and server_script. The manual's own example uses server_script 'server.lua' next to a client_scripts block, so both styles appear in practice.
A small example
This example uses placeholder names. Replace my-resource and the event names with your own.
client.lua
-- Send a message from the client to the server
TriggerServerEvent('my-resource:ping', 'hello from the client')
-- Receive a message sent from the server
RegisterNetEvent('my-resource:pong', function(message)
print(message)
end)
server.lua
-- Receive the message from the client
RegisterNetEvent('my-resource:ping', function(message)
print(message)
-- Send a reply to all connected players (-1 means all)
TriggerClientEvent('my-resource:pong', -1, 'hello from the server')
end)
Both sides call RegisterNetEvent for the event names they listen to. The client only sends with TriggerServerEvent, and the server only sends to clients with TriggerClientEvent.
Common mistakes
- Trusting client data. A player can send any value in an event. The manual says data from the client should never be trusted and should be verified on the server. Check the value on the server before using it for money, items or permissions.
- Calling server-only functions in client scripts.
TriggerClientEventis a server-side call, so putting it in a client script is a mistake. Events also have a side: client events are listened for in client scripts, and server events in server scripts. - Forgetting
RegisterNetEvent. Lua events must be registered before they work across the network. - Sending large data in one event. The manual advises keeping event data small. For larger transfers, the reference points to
TriggerLatentServerEvent.
FAQ
Can a client script read a variable from the server?
No. Send the value to the client with TriggerClientEvent, and read it in a RegisterNetEvent handler on the client.
Where should I check money or permissions?
On the server. Anything a player's game sends can be changed, so the server should check the value before it acts on it.
What is shared_scripts for?
It loads a file on both the client and the server. Use it for code that both sides need, such as shared settings.
Sources
- Introduction to Resources, FiveM scripting manual
- Resource Manifest, FiveM scripting reference
- Triggering Events, FiveM scripting manual
- Listening for Events, FiveM scripting manual
- TriggerServerEvent, FiveM Lua reference
Last checked: 29 November 2026
Not confirmed: I did not check every function against a full reference page, so the lists of what works only on the client or only on the server are not complete here. I did not check forum.cfx.re discussions. The advice on payload size came from a search summary, not a full read of the page.
FiveM.tools was founded with sponsorship from Nyru.