ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
client

TriggerServerEvent

FiveM client native documentation with a Lua example.

Summary

Fires a registered event on the server from the client. The primary way the client asks the server to do something. The server must have a matching RegisterNetEvent handler.

Returns

void

Parameters

eventNamestringThe event name to trigger on the server.
...anyAny arguments to pass to the server handler.

Example

-- CLIENT
TriggerServerEvent('myscript:buyItem', itemId, quantity)

-- SERVER
RegisterNetEvent('myscript:buyItem', function(itemId, quantity)
  local src = source -- the player who triggered it
  -- ALWAYS validate server-side before trusting anything
end)

Common pitfalls

  • NEVER trust arguments from the client blindly — a cheater can send anything. Validate everything server-side.
  • The server handler must use RegisterNetEvent (not just AddEventHandler) to receive client-triggered events.
  • On the server, use source to know which player triggered it — capture it immediately, it can change.

Related natives

Related guides

FiveM scripts done right

Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.

Browse Scripts →