Client, server, shared: three folders, one resource
Open almost any serious FiveM resource and you see the same three folders: client/, server/, and shared/. They are not decoration. Each one runs in a different place, and putting a line in the wrong folder is how beginners leak secrets, crash the client, or wonder why a value is nil. This lesson builds the split for real and then teaches the rule for deciding where every line you write belongs.
Build it
Make the resource folder
Inside your server's resources folder, create this folder:
resources/qu_client_server_shared
Create the three folders and their files
Create this exact layout. The folder names are the convention you will see everywhere:
resources/qu_client_server_shared/
fxmanifest.lua
shared/
config.lua
server/
main.lua
client/
main.lua
Write fxmanifest.lua
Open fxmanifest.lua and paste this:
fx_version 'cerulean'
game 'gta5'
shared_scripts {
'shared/*.lua'
}
server_scripts {
'server/*.lua'
}
client_scripts {
'client/*.lua'
}
Older tutorials add a lua54 'yes' line here. As of June 2025 that setting is deprecated and you do not need it: Lua 5.4 is the only Lua runtime now, so you leave it out.
Write the shared config
Open shared/config.lua and paste this:
Config = {}
Config.Greeting = 'three folders, one resource'
Config.MaxDistance = 25.0
Write the server code
Open server/main.lua and paste this:
print('[qu_client_server_shared] server read Config.Greeting: ' .. Config.Greeting)
RegisterCommand('splitproof', function(src)
print('[qu_client_server_shared] server fired splitproof for src ' .. src)
TriggerClientEvent('qu_client_server_shared:proof', src, Config.MaxDistance)
end, false)
Write the client code
Open client/main.lua and paste this:
print('[qu_client_server_shared] client read Config.Greeting: ' .. Config.Greeting)
RegisterNetEvent('qu_client_server_shared:proof', function(maxDistance)
print('[qu_client_server_shared] client received event, Config.MaxDistance = ' .. maxDistance)
end)
Start and test it
Open server.cfg and add this line:
ensure qu_client_server_shared
Save. In the server console (the txAdmin Live Console you opened in the prerequisites), run these two commands:
refresh
ensure qu_client_server_shared
refresh rereads every fxmanifest.lua so FiveM sees the files you just created. ensure starts the resource. After this, when you edit a file, run restart qu_client_server_shared to reload it.
Join the server, open the in-game chat box with T, and run:
/splitproof
The false at the end of RegisterCommand means the command is not restricted, so any player can run it. When a connected player runs it, the handler's src is that player's id, such as 1. Run it from the server console instead and src is 0, which is not a connected client, so TriggerClientEvent has nobody to send to.
config.lua is a shared_script, so it loads on both sides; client and server files never cross.Keep reading the full lesson
Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.
- How it works
- If something went wrong
- What you can do now
- Try it yourself
The remainder of Client, server, shared is available to FiveM School members.