-- This example detaches a specific entity from a Cargobob.
-- Retrieve the player ped.
local playerPed = PlayerPedId()
-- Retrieve the player's vehicle (cargobob).
local cargobob = GetVehiclePedIsIn(playerPed, false)
-- Retrieve the model hash of the cargobob.
local cargobobModel = GetEntityModel(cargobob)
-- Check if the vehicle exists and if it's a Cargobob. If not, terminate the script.
if not DoesEntityExist(cargobob) or cargobobModel ~= GetHashKey("cargobob") then
return
end
local entityID = 15362 -- The entity you want to detach from the Cargobob (this is a random entity ID).
-- Check if the entity exists; if not, terminate the script.
if not DoesEntityExist(yourEntity) then
return
end
-- Detach the entity from the Cargobob.
DetachEntityFromCargobob(cargobob, entityID)