# setControlState (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/setControlState-client
- **Counterpart**: Also exists on the server, with its own implementation: [setControlState (Server)](https://wiki.mymp.gg/en/setControlState-server.md)

## Syntax

```lua
bool setControlState(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
addCommandHandler("autorun", function()
    local running = not getControlState("forwards")
    setControlState("forwards", running)
    setControlState("sprint", running)
end)
```

### 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

- [getControlState (Client)](https://wiki.mymp.gg/en/getControlState-client.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 (Server)](https://wiki.mymp.gg/en/setControlState-server.md): Presses or releases one of a player's controls as if it were a key. The order goes to their client, which applies it as setControlState on the local player.
