ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
shared

DoesEntityExist

FiveM shared native documentation with a Lua example.

Summary

Checks whether an entity handle still refers to a real, existing entity. Essential before using any handle that could be stale (networked entities, spawned vehicles, deleted objects).

Returns

boolean — true if the entity exists.

Parameters

entitynumberThe entity handle to check.

Example

local veh = NetworkGetEntityFromNetworkId(netId)
if DoesEntityExist(veh) then
  SetVehicleNumberPlateText(veh, 'OK')
end

Common pitfalls

  • Always check this before acting on a handle you got from a network ID or stored earlier — handles go stale.
  • A handle of 0 never exists; this catches that and deleted entities too.

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 →