# setPedControlState (Client)

> Presses or releases one of a ped's controls as if it were a key, for example to make it walk, jump or shoot.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Controls
- **URL**: https://wiki.mymp.gg/en/setPedControlState

## Syntax

```lua
bool setPedControlState(string control, bool state [, ped thePed = localPlayer])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `thePed` | `ped` | The ped or the local player. It can be left out, which means the local player. *(default: `localPlayer`)* |
| `control` | `string` | The control's name, case insensitive. |
| `state` | `bool` | `true` to hold it down, `false` to release it. |

## Returns

`true` if the state was applied. `false` if the control name does not exist or the ped cannot take controls.

On an analog control (walking, steering, accelerating, braking), `true` presses it all the way and releases the opposite control. A control turned off with `toggleControl` does not reach the game, even when a script presses it.

## Example

```lua
local ped = createPed("male01", 2495.0, -1685.0, 13.5)
setPedControlState(ped, "forwards", true)
setTimer(function()
    setPedControlState(ped, "forwards", false)
end, 3000, 1)
```

### Coming from MTA

Besides MTA's controls, MYMP has `block` (melee block) and `reload`.

### Note

On a remote player the function returns `true` but does nothing. On the local player, the player's own input on that control replaces the script's state.

## See also

- [getPedControlState (Client)](https://wiki.mymp.gg/en/getPedControlState.md): Tells whether one of a ped's controls is pressed, such as forwards, fire or accelerate.
- [setPedAnalogControlState (Client)](https://wiki.mymp.gg/en/setPedAnalogControlState.md): Presses one of a ped's analog controls only partly, for example to make it walk slowly or steer gently.
- [toggleControl (Client)](https://wiki.mymp.gg/en/toggleControl-client.md): Turns one of the local player's controls on or off. A control that is off does not reach the game, even with its key held down.
- [setControlState (Client)](https://wiki.mymp.gg/en/setControlState-client.md): Presses or releases one of a ped's controls as if it were a key, for example to make it walk, jump or shoot.
