Create a mod and script with FiveM
In this tutorial, we will see how to create a Lua script and run it in GTA V via FiveM.
Prerequisites:
- GTA V installed
- FiveM (client + txAdmin server) installed
Preparing the mod in the FiveM server
When installing the local txAdmin server, a resources folder is created. We will add our script there.
Example path: C:\Users\$User\Desktop\txData\FiveMBasicServerCFXDefault_BC1780.base\resources
- In
resources, create a new folder and name itscript_mod(or any name you prefer). - Add an
fxmanifest.luafile inscript_modand add the following code to it.
fx_version 'cerulean'
game 'gta5'
author 'An awesome dude'
description 'An awesome, but short, description'
version '1.0.0'
resource_type 'gametype' { name = 'My awesome game type!' }
client_script 'monscript.lua'
- Create a new file
monscript.luain the same folder and paste the following code:
local spawnPos = vector3(-22.28888, 18.04243, 72)
AddEventHandler('onClientGameTypeStart', function()
exports.spawnmanager:setAutoSpawnCallback(function()
exports.spawnmanager:spawnPlayer({
x = spawnPos.x,
y = spawnPos.y,
z = spawnPos.z,
model = 'a_f_y_yoga_01'
}, function()
print("Player spawned at custom location with custom model.")
end)
end)
exports.spawnmanager:setAutoSpawn(true)
exports.spawnmanager:forceRespawn()
end)
- Open the
server.cfgfile (located at the root of the server) with a text editor and add the following line:
start script_mod
Tip: place this line at the end of the file, after the other resources already listed, to avoid any loading order conflict.
- Launch the txAdmin server.
- Launch the FiveM client, connect to your local server.
If everything is correctly configured, your character will appear at the position (-22.28888, 18.04243, 72.0) with the model a_f_y_yoga_01.
Reload the script without restarting the game
It is not necessary to close GTA V for every modification:
- Modify your
monscript.luafile in a code editor. - Save the changes.
- Go back to GTA V, open the console with F8 and type:
restart script_mod
The restart command reloads the entire resource, which runs the Lua code again.
You can also recall the last command with the keyboard's ↑ arrow, like in a terminal.
Translated by AI from the French version.



