# createElement (Shared)

> Creates an element of a type the script makes up, with nothing in the world. It goes under the resource's dynamic element root.

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

## Syntax

```lua
element|false createElement(string type [, string id = ""])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `type` | `string` | The type's name, what `getElementType` will return. |
| `id` | `string` | The element's ID, the same as `setElementID`. *(default: `""`)* |

## Returns

The created element, or `false` if there is no room for more elements.

The element belongs to the resource that created it and is destroyed when the resource stops.

## Example

```lua
local zone = createElement("spawnzone", "spawn_grove")
setElementData(zone, "radius", 25)
```

## See also

- [destroyElement (Shared)](https://wiki.mymp.gg/en/destroyElement.md): Destroys an element and all of its children. Before it goes, each one fires onElementDestroy on the server or onClientElementDestroy on the client.
- [setElementID (Shared)](https://wiki.mymp.gg/en/setElementID.md): Gives an element an id (a name), to find it later with getElementByID.
- [getElementsByType (Server)](https://wiki.mymp.gg/en/getElementsByType-server.md): Lists every element of a type below an element of the tree on the server.
- [getResourceDynamicElementRoot (Shared)](https://wiki.mymp.gg/en/getResourceDynamicElementRoot.md): Returns the element under which the elements the resource creates by script are placed. It is a child of the resource's element and is called dynamic.
