# AddEntity

## AddEntity

This export does the equivalent of AddTargetEntity

### Arguments

<table><thead><tr><th>Argument</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>identifier</td><td>The unique string identifier of this target, in-case you want to remove it later</td><td></td></tr><tr><td>entities</td><td>A single, or table of, entities that the target should be for</td><td></td></tr><tr><td>options</td><td>The options for the target (see <a data-mention href="../options-formatting">options-formatting</a>)</td><td></td></tr></tbody></table>

### Usage

```lua
exports['nyx2_target']:AddEntity(identifier, entities, options)
```

### Example

```lua
local boxCoords = vector3(-74.41, -823.88, 326.18)
local boxModel = GetHashKey('prop_boxpile_07d')

RequestModel(boxModel)
while not HasModelLoaded(boxModel) do
    Wait(0)
end

local box = CreateObject(boxModel, boxCoords.x, boxCoords.y, boxCoords.z - 1.0, false, false, false)
SetEntityAsMissionEntity(box, true, true)
SetEntityAlpha(box, 255, false)
SetModelAsNoLongerNeeded(boxModel)

exports['nyx2_target']:AddEntity('debug_box_entity', box, {
    {
        title = 'Debug Box Entity',
        icon = 'fas fa-box',
        action = function(zone)
            local QBCore = exports['qb-core']:GetCoreObject()
            QBCore.Functions.Notify('This is a box!', 'success')
        end,
        canInteract = function(zone)
            return true
        end,
        job = nil, -- if nil, all jobs can interact
        gang = nil, -- if nil, all gangs can interact
        citizenid = nil, -- if nil, all players can interact
        item = nil, -- if nil, don't require an item to interact
    }
})
```

## RemoveEntity

This export removes a entity target that you have created.

<table><thead><tr><th>Argument</th><th>Description</th><th data-hidden></th></tr></thead><tbody><tr><td>identifier</td><td>The unique string identifier of the target you want to remove</td><td></td></tr></tbody></table>

### Example

```lua
exports['nyx2_target']:RemoveEntity('debug_box_entity')
```
