ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
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

Need protected areas on your map?

Viper Safe-Zone draws polygon safe zones in-game — no hand-edited coordinates — with weapon, combat and vehicle-speed rules per zone.

See Viper Safe-Zone →