# setElementID (Shared)

> Gives an element an id (a name), to find it later with `getElementByID`.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Elements
- **URL**: https://wiki.mymp.gg/en/setElementID

## Syntax

```lua
bool setElementID(element element, string id)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The element. |
| `id` | `string` | The new id. |

## Returns

`true` if it was set, `false` if the element came from the server and the function runs on a client.

## Example

```lua
local spawn = createElement("spawnpoint")
setElementID(spawn, "lobby")

local found = getElementByID("lobby")
```

## See also

- [getElementID (Shared)](https://wiki.mymp.gg/en/getElementID.md): Reads an element's ID, the name getElementByID looks for.
- [getElementByID (Shared)](https://wiki.mymp.gg/en/getElementByID.md): Finds the first element with an ID, starting at an element and going down through its children.
