ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
QBCoreserver

Player.Functions.GetItemByName

QBCore server documentation with a FiveM Lua example.

Summary

Gets a player's item (and amount) by name in QBCore's inventory. Check before removing or gating actions on having an item.

Returns

table|nil — the item, or nil if not held.

Parameters

itemstringThe item name.

Example

local Player = QBCore.Functions.GetPlayer(src)
local itm = Player.Functions.GetItemByName('lockpick')
if itm and itm.amount > 0 then
  -- has a lockpick
end

Common pitfalls

  • Returns nil when the player doesn't have it — null-check.
  • On ox_inventory servers, use ox_inventory:Search instead.

Related functions

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 →