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.

Create a basic FiveM script from zero

Every FiveM resource starts with three things: a folder, a manifest, and a script. This lesson builds the simplest possible resource - one that prints to console, responds to a chat command, and detects a key press. By the end you understand the skeleton that every other lesson builds on.

You'll build
A resource that prints to console, registers a chat command, and responds to a key press.
Time
~15 minutes
You need
A local FiveM server, a text editor, and access to your resources folder.
You'll learn
The minimum files every resource needs, how to create a thread that runs on start, RegisterCommand for chat commands, and IsControlJustPressed for key binds.
BEFORE YOU START

Build it

Create the folder and manifest

FiveM recognizes your resource.
code
resources/qu_first_script/
fxmanifest.lua
client.lua
code
fx_version 'cerulean'
game 'gta5'

client_script 'client.lua'

Restart the resource: ensure qu_first_script in server console or txAdmin Live Console.

Print to console on resource start

F8 console shows your message.
code
-- Runs once when the resource starts
CreateThread(function()
print('Hello from my first script!')
end)

Open F8 in-game. Restart the resource with ensure qu_first_script. You should see your message.

Add a chat command

Typing /hello in chat prints a response.
code
-- Register a command players can type in chat
RegisterCommand('hello', function(source, args)
print('Player typed /hello')
print('Arguments: ' .. json.encode(args))
end, false)

In-game, open chat (T) and type /hello world. The args table contains everything after the command name.

Detect a key press

Pressing a key triggers your code.
code
-- Check for key presses every frame
CreateThread(function()
while true do
    if IsControlJustPressed(0, 38) then  -- 38 = E key
        print('E key pressed!')
    end
    Citizen.Wait(0)
end
end)

IsControlJustPressed returns true only on the frame the key was first pressed - it won't spam. Full control list: https://docs.fivem.net/docs/game-references/controls/

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
  • Common failures

The remainder of Create a basic FiveM script from zero is available to FiveM School members.