> For the complete documentation index, see [llms.txt](https://maxim218.gitbook.io/unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maxim218.gitbook.io/unity/dobavlenie-i-udalenie-skriptov.md).

# Добавление и удаление скриптов

Переменная для хранения игрового объекта.

```
private GameObject cubeObj;
```

Находим объект на сцене.

```
cubeObj = GameObject.Find("Cube");
```

Добавляем скрипт к объекту.

```
cubeObj.AddComponent<myMovingScript>();
```

Удаляем скрипт с объекта.

```
myMovingScript scr = cubeObj.GetComponent<myMovingScript>();
if (scr)
{
    Destroy(scr);
    Debug.Log("SCRIPT KILLED");
}
```
