# getResourceRootElement (Shared)

> Returns a resource's root element, the same as that resource's `resourceRoot` global.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Resources and modules
- **URL**: https://wiki.mymp.gg/en/getResourceRootElement

## Syntax

```lua
element|false getResourceRootElement([resource|string resource = getThisResource()])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `resource` | `resource\|string` | The resource, or its name. Without it, the calling resource. *(default: `getThisResource()`)* |

## Returns

The element, or `false` if the resource is not running.

## Example

```lua
local mapRoot = getResourceRootElement("race-map")
if mapRoot then
    addEventHandler("onResourceStop", mapRoot, function()
        outputServerLog("the map stopped")
    end)
end
```

### Coming from MTA

The root element is the resource's own element: it is the same one `getThisResource` returns.

## See also

- [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.
- [getThisResource (Shared)](https://wiki.mymp.gg/en/getThisResource.md): Returns the resource the script is running in.
- [getRootElement (Shared)](https://wiki.mymp.gg/en/getRootElement.md): Returns the root element, the top of the element tree. It is the same value as the global root.
