client
GetPlayerPed
FiveM client native documentation with a Lua example.
Summary
Returns the ped handle for a given player index. Use PlayerPedId() for the local player instead — it's faster and simpler.
Returns
Ped (number) — the ped handle, or 0 if invalid.
Parameters
playerIndexnumberThe player index. Use -1 for the local player, though PlayerPedId() is preferred for that.Example
-- For the local player, prefer:
local ped = PlayerPedId()
-- For a specific player index:
local targetPed = GetPlayerPed(playerIndex)
local coords = GetEntityCoords(targetPed)Common pitfalls
- Don't call GetPlayerPed(-1) repeatedly in a loop — cache PlayerPedId() instead and refresh it when the ped changes.
- The ped handle changes when the player respawns or their model changes, so don't store it long-term.
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 →