Skip to main content
TRACK B·BUILD REAL PRODUCTS·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.

/heal command, your first script

By the end of this lesson you will type /heal in chat and watch your character refill to full health, with this command's cooldown enforced on the server.

You'll ship
A working /heal command that heals only the player who typed it, with a 60 second cooldown.
Time
About 25 minutes if you go slow.
You'll learn
How a chat command becomes code, and why the server is the one allowed to say yes.
Prereqs
You can start a FiveM server and edit a file. That is enough.
Quasar School: the revive / heal command.
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_heal_command

Create the files

Every file named in the manifest exists.

Create this exact file layout:

code
resources/qu_heal_command/
fxmanifest.lua
server.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'
server_script 'server.lua'

Write the lesson code

The topic is now represented by runnable code.

Open server.lua and paste this:

code
local cooldown = {}

RegisterCommand('heal', function(src)
local now = os.time()
if cooldown[src] and now - cooldown[src] < 60 then
    TriggerClientEvent('qu_heal_command:deny', src, 60 - (now - cooldown[src]))
    return
end
cooldown[src] = now
TriggerClientEvent('qu_heal_command:heal', src)
print('[qu_heal_command] approved heal for ' .. GetPlayerName(src))
end, false)

Open client.lua and paste this:

code
RegisterNetEvent('qu_heal_command:heal', function()
local ped = PlayerPedId()
SetEntityHealth(ped, GetEntityMaxHealth(ped))
print('[qu_heal_command] healed')
end)

RegisterNetEvent('qu_heal_command:deny', function(seconds)
print('[qu_heal_command] wait ' .. seconds .. ' seconds')
end)

Start and test it

The expected proof appears in the correct console.

Open server.cfg and add this line:

code
ensure qu_heal_command

Save. Now start the resource in the live console (txAdmin Live Console or the FXServer console window) by typing:

code
ensure qu_heal_command

Use ensure, not restart, the first time: the line you just added to server.cfg is only read when the whole server boots, so on an already-running server the resource has not started yet. restart only works on a resource that is already running, so it would do nothing here. ensure starts the resource if it is stopped and restarts it if it is already running, so it always works.

Join your own server, wait until your character has spawned in, then open the in-game chat box (press the chat key, by default T) and type the command, then press Enter:

code
/heal

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
  • Now revive someone else
  • If something went wrong
  • What you can do now
  • Try it yourself

The remainder of /heal command: your first build is available to FiveM School members.