# onResourceStop (Server)

> Fired when a resource is about to stop, while its scripts and elements still exist.

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

## Syntax

```lua
addEventHandler("onResourceStop", root, function(resource stoppedResource) ... end)
```

## Handler parameters

| Name | Type | Description |
| --- | --- | --- |
| `stoppedResource` | `resource` | The resource about to stop. |

## Source

The element of the resource about to stop.

With a handler on `resourceRoot`, only the resource itself; with one on `root`, every resource.

## Example

```lua
addEventHandler("onResourceStop", resourceRoot, function(stoppedResource)
    for _, player in ipairs(getPlayers()) do
        setElementData(player, "score", nil)
    end
end)
```

## See also

- [onResourceStart (Server)](https://wiki.mymp.gg/en/onResourceStart.md): Fired when a resource has finished starting, after its scripts and maps have run.
- [stopResource (Shared)](https://wiki.mymp.gg/en/stopResource.md): Asks to stop a running resource. It stops on the next resource pulse, not during the call.
- [restartResource (Shared)](https://wiki.mymp.gg/en/restartResource.md): Asks to stop and start again a running resource. It happens on the next resource pulse, not during the call, and the resource keeps its place in the start order.
- [getResourceName (Shared)](https://wiki.mymp.gg/en/getResourceName.md): Returns a resource's name.
