Skip to main content
TRACK B·YOUR FIRST RESOURCE·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this lesson plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.

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.

You'll build
A three-folder resource where a shared config table is read by both the client and the server, proven across the network with one command.
Time
~20 minutes
You need
A local FiveM practice setup you can restart, a text editor, and the ability to read both txAdmin Live Console and F8 output.
You'll learn
The client / server / shared split, the decision rule for what goes where, why shared runs on both sides, glob imports, and what must never live in shared
BEFORE YOU START

Build it

Make the resource folder

The server has one folder for this lesson.

Inside your server's resources folder, create this folder:

code
resources/qu_client_server_shared

Create the three folders and their files

The three-folder convention exists on disk.

Create this exact layout. The folder names are the convention you will see everywhere:

code
resources/qu_client_server_shared/
fxmanifest.lua
shared/
config.lua
server/
main.lua
client/
main.lua

Write fxmanifest.lua

FiveM loads each folder into the right runtime.

Open fxmanifest.lua and paste this:

code
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

One config table that both sides will read.

Open shared/config.lua and paste this:

code
Config = {}
Config.Greeting = 'three folders, one resource'
Config.MaxDistance = 25.0

Write the server code

The server reads shared config and fires an event across the network.

Open server/main.lua and paste this:

code
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

The client reads the same shared config and receives the server's event.

Open client/main.lua and paste this:

code
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

The shared value appears on both sides, and the event crosses the network.

Open server.cfg and add this line:

code
ensure qu_client_server_shared

Save. In the server console (the txAdmin Live Console you opened in the prerequisites), run these two commands:

code
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:

code
/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.

fx_version 'cerulean'
game 'gta5'
CLIENT
client.lua
config.lua
SERVER
config.lua
server.lua
Click a manifest line to toggle it. Notice 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.

Still ahead in this lesson
  • 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.