Skip to main content
TRACK B·FIVEM FUNDAMENTALS·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.

TriggerEvent: how scripts talk to each other

A real FiveM server runs lots of resources at the same time. They do not share variables directly, so they need a way to talk. That is what events are. An event is just a named message. One script fires it, another script listens for it. This lesson starts with the simplest version: same-side events using TriggerEvent.

You'll learn
TriggerEvent -> AddEventHandler -> passing arguments -> the same-side rule for local events
Time
~22 minutes
Prereqs
Module 03 complete, you understand client vs server as separate processes.
Outcome
Two resources that hold a conversation on the same side, one firing events, the other reacting.
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_trigger_event

Create the files

Every file named in the manifest exists.

Create this exact file layout:

code
resources/qu_trigger_event/
fxmanifest.lua
client.lua

Write fxmanifest.lua

FiveM knows which files to load.

Open fxmanifest.lua and paste this:

code
fx_version 'cerulean'
game 'gta5'

client_script 'client.lua'

No lua54 'yes' line. As of June 2025 that directive is deprecated and you no longer need to enable it: Lua 5.3 has been deprecated and every Lua script now runs on Lua 5.4 automatically, so you leave it out.

Write the lesson code

The topic is now represented by runnable code.

Open client.lua and paste this. Two handlers listen for the same event name, and one command fires that event:

code
AddEventHandler('qu_trigger_event:shout', function(message)
print('[qu_trigger_event] handler one ' .. message)
end)

AddEventHandler('qu_trigger_event:shout', function(message)
print('[qu_trigger_event] handler two ' .. message)
end)

RegisterCommand('shout', function(_, args)
TriggerEvent('qu_trigger_event:shout', table.concat(args, ' '))
end, false)

Start and test it

The expected proof appears in the correct console.

Open server.cfg and add this line:

code
ensure qu_trigger_event

Save, then run:

code
restart qu_trigger_event

This is a client_script, so the command runs from inside the game. Run /shout hello in chat, or type shout hello without a slash in F8.

code
Chat: /shout hello
F8: shout hello

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 TriggerEvent: same-side is available to FiveM School members.