# setElementModel (Server)

> Changes the model of a ped or player, and of its children.

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

## Syntax

```lua
bool setElementModel(element element, string model)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `element` | `element` | The ped or player. |
| `model` | `string` | The ped model's name. |

## Returns

`true` if the element's own model changed, `false` if the model is the same, is not a ped model, the element is not a ped or player, or a handler cancelled the change.

Fires `onElementModelChange` with the old and the new model. Cancelling the event goes back to the old model.

## Example

```lua
addCommandHandler("skin", function(player, command, model)
    if model and not setElementModel(player, model) then
        outputDebugString("unknown ped model: " .. model)
    end
end)
```

## See also

- [getElementModel (Shared)](https://wiki.mymp.gg/en/getElementModel.md): Reads the name of an element's model.
- [onElementModelChange (Server)](https://wiki.mymp.gg/en/onElementModelChange.md): Fired after setElementModel changes an element's model. Cancelling the event puts the previous model back, and setElementModel returns false.
- [createPed (Server)](https://wiki.mymp.gg/en/createPed-server.md): Creates a ped on the server, seen by every player.
