# Creating an empty gamemode

A gamemode is a feature provided by the `core` modules, as part of the normal level load and initialization process. It means you can attach a game mode to specific levels and then whenever you load that [level](/for-designers/scenes-and-levels.md), the gamemode will be activated.

Before you dive into this part of the tutorial, make sure to create an empty level in the CoinCollection module. Open the [World Editor](/getting-started/getting-familiar/launching-the-game/launching-the-editors.md), click on `File` in the top-left toolbar and choose `New Level` then click `Save Level` and make sure to place it in our CoinCollection module like this:

![](/files/zSmCRYAnt8cWTywjbYhs)

### The game mode

We need to be able to initialise the game mode, create a new file in `data/CoinCollection/server/gamemode.tscript` with the following contents:

```csharp
function CoinCollectionGameMode::onCreateGame() {
    // Note: The Game object will be cleaned up by MissionCleanup.  
    // Therefore its lifetime is limited to that of the mission.
    new ScriptObject(CoinCollectionGameMode) {
    };

    return CoinCollectionGameMode;
}
```

This is a *static* method and it is called from the `core` scripts.

Add the following piece of code to the end of `gamemode.tscript`:

```csharp
function CoinCollectionGameMode::onMissionStart(%this) {
    echo("CoinCollection mission has been loaded");
}
```

This does what it says on the tin, it's a method on the `CoinCollectionGameMode` object that is triggered when the mission starts, after the mission finish loading.

Since we added a new script file, we'll need to execute it, in the file `data/CoinCollection/CoinCollection.tscript` , change the function `initServer` to the following:&#x20;

```csharp
function CoinCollection::initServer(%this) {
    %this.queueExec("./server/gamemode.tscript");
}
```

Now, we need to associate our gamemode with the level. First select the scene object in the scene tree:\
![](/files/xO2TLXvMBWa4rouqYjmm)

Then set the gameModeName of the scene object to `CoinCollectionGameMode`:

![](/files/Lt4eFrwEHW7p1WXXqleH)

Remember to save your level.

Finally, go back to the main menu, click `Single Player`, choose your level and run it. Then look in the Console (tilde on US-layouts, for me it's the ½ key), and see if the message "CoinCollection mission has been loaded" is printed.

If it is, then awesome! Your gamemode is working! However, it's a rather boring game, you can't really move around in the game or do anything really.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.torque3d.org/getting-started/getting-familiar/your-first-game/creating-an-empty-gamemode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
