> For the complete documentation index, see [llms.txt](https://danil-dukhovenko.gitbook.io/force/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danil-dukhovenko.gitbook.io/force/force-editor/scripting/using-scripts.md).

# Using Scripts

To make script that he can execute code from, its need to be attached to a GameObject. Before that we need to create script component for our **GameObject**. So **COMPONENT** -> **CSharpScript** do that. Or you can click on **GameObject -> Components Menu** and choose **CsScriptComponent** from there.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FXv9ZrxQDy8MQu2cF0saj%2Fimage.png?alt=media&amp;token=038b8cce-6ea1-4440-8912-ba5d9d3aa399" alt=""><figcaption><p>Selecting CsScript component in Components Menu</p></figcaption></figure></div>

After that this component will be add to our **GameObject**:

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2F7NwP5edK6Ss0C6JhSLl0%2Fimage.png?alt=media&amp;token=2948a246-70fc-43af-9daa-fc2b44170407" alt=""><figcaption><p>Script Component</p></figcaption></figure></div>

And then we just need to drag the asset of the script from the browser, that we created **Script** early into the field for the item of selected **GameObject**. So when script is attached, it already create that instance that we discuss early and can be executable.

Before we write first line of script code,I wont to say that just like in **Visual Studio**, you can compile the script right here by clicking on ![](https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FW0KLFsbTQNiYQvV0GLWK%2Fimage.png?alt=media\&token=6648a59f-e95d-4d5c-957b-b8f1a146f3f6)button on the **Gameplay Toolbar** or by pressing **Ctrl+F5**. This very useful when you write script in simple notepad.&#x20;

But basically now **Force** (0.4+) will automatically recompile all scripts when any script file will be modified, move, removed, added.

```csharp
using Force;

public class NewScript : MonoScript {

	// Runs when scene starts to play.
	public void OnStart() {
		Debug.Log("Hello world, together we are - Force!");
	}
}
```

`Debug.Log()` function called from utility class **Debug**, and its job is just log the input text in to **Console Log** window in editor.

Now press the **Play** button and see the results.

<div align="left"><figure><img src="https://2773422523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuytHSSE0uhny7g4jsNpY%2Fuploads%2FqwkNQvH8i8KzVtNPlXDf%2Fimage.png?alt=media&amp;token=f2439733-e31c-46ff-8719-9c224d8f8e8a" alt=""><figcaption><p>Message "Hello world, together we are - Force!" from script</p></figcaption></figure></div>

###
