Reset Button: How to Make Your Island Start Over
Tutorial beginner compiles

Reset Button: How to Make Your Island Start Over

Updated beginner Code verified

Reset Button: How to Make Your Island Start Over

Have you ever finished a puzzle and wanted to play it again? Or maybe you won a race and wanted to see if you could beat your time? In Fortnite islands, we use a special command called Reset to make things go back to the start.

This is like hitting "New Game" in your favorite video game. It clears the score and puts all the blocks back where they belong. In this tutorial, we will build a simple color-changing tile game. We will use Verse code to add a button that restarts the whole round. You will learn how to control devices with code. Let's get building!

What You'll Learn

  • What a Device is in UEFN.
  • How to use the Reset function to clear progress.
  • How to connect a button to a game mechanic.
  • How to write simple Verse code to control your island.

How It Works

Imagine you are playing with building blocks. You stack them high. Then you knock them all down. Now you can build again. That is what Reset does. It takes a device and sends it back to its starting state.

In Fortnite islands, we use Devices. Devices are special objects that do things. They are like magic boxes. You can place them in your world. They have settings you can change in the editor. But sometimes, you want to change them during the game. That is where Verse comes in.

Verse is the programming language for Fortnite. It lets you tell devices what to do. Think of Verse as the instructions you give to a robot. If you say "Reset," the robot puts the blocks back in the box.

We will use a Color Changing Tile. This device changes color when a player steps on it. It is great for memory games or color matching. But once all tiles change, the game is over. We need a way to start over. We will add a Conditional Button. When you press it, Verse will tell the tiles to reset.

Let's Build It

First, let's set up our world. We need three things:

  1. Color Changing Tiles: Place two or three of these on the ground.
  2. A Conditional Button: Place this near the tiles.
  3. A Verse Script: This is the brain of our game.

We will write a script that listens for the button press. When the button is pressed, it calls Reset on the tiles.

Here is the code. Copy this into a new Verse file in your project.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our main script block.
# Think of it as the container for our game rules.
# In UEFN, we declare devices as editable properties so the
# editor can wire up the correct objects from the World Outliner.
reset_game_script := class(creative_device):

    # We need to tell Verse which tiles to reset.
    # Select this device in the editor and assign your
    # Color Changing Tiles in the Details panel.
    @editable
    Tile1 : color_changing_tiles_device = color_changing_tiles_device{}

    @editable
    Tile2 : color_changing_tiles_device = color_changing_tiles_device{}

    # We also need the button that triggers the reset.
    # Assign your Conditional Button in the Details panel.
    @editable
    Button : button_device = button_device{}

    # OnBegin runs once when the island starts.
    # It waits for the button to be pressed.
    OnBegin<override>()<suspends> : void =
        # We connect the button's "InteractedWithEvent" to our handler.
        # When the button is clicked, ResetGameScript runs.
        Button.InteractedWithEvent.Subscribe(ResetGameScript)

    # This is our reset handler function.
    # It is called every time the button is pressed.
    ResetGameScript(Agent : agent) : void =
        # This is the magic line!
        # It tells each tile to go back to its start color.
        Tile1.Reset()

        # Reset the second tile too.
        Tile2.Reset()```

### Walkthrough of the Code

Let's break down what each part does.

First, we use `using { /Fortnite.com/Devices }`. This tells Verse to look for device commands. It is like opening your toolbox.

Next, we define `reset_game_script`. This is a **class** that extends `creative_device`. A class is a blueprint for our game logic. It holds both our device references and the instructions for what to do with them.

Inside the class, we use `@editable` to mark `Tile1`, `Tile2`, and `Button`. The `@editable` tag makes these show up in the UEFN Details panel. You click on your script device in the editor and drag your tiles and button into those slots. That is how Verse knows which objects in your world to control. No name-matching needed!

Then comes `Tile1.Reset()` and `Tile2.Reset()`. These are the core commands. Each one sends a signal to its tile. The tile hears the signal and changes its color back to the start.

Finally, `OnBegin` is a special function. It runs once when the game starts. We use `Subscribe` to connect the button's `InteractedWithEvent` to our `ResetGameScript` handler. This means the script waits for a click. When it happens, the reset happens too.

## Try It Yourself

Now it is your turn to build!

**Challenge:** Add a third tile to your game. Make sure the reset button resets *all* tiles, not just one.

**Hint:** You will need to add a new `@editable` property like `Tile3 : color_changing_tiles_device = color_changing_tiles_device{}`. Then, add another line like `Tile3.Reset()` inside your `ResetGameScript` function. Don't forget to assign the third tile in the Details panel in the editor!

Take your time. Test it out. If the tiles don't reset, check that you have assigned the correct devices in the Details panel. Small mistakes are part of learning. You are doing great!

## Recap

You just built a resettable game mechanic. You learned that devices are magic boxes that do actions. You used the `Reset` function to send them back to the start. You connected a button to a script with Verse. Now you can make games that players can replay forever. Keep experimenting and having fun!

## References

- https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/capture_area_device/reset
- https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/conditional_button_device/reset
- https://dev.epicgames.com/documentation/en-us/uefn/verse-api/fortnitedotcom/devices/color_changing_tiles_device/reset
- https://dev.epicgames.com/documentation/en-us/fortnite/verse-api/fortnitedotcom/devices/capture_area_device/reset
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/capture_area_device/reset

Verse source files

Turn this into a guided course

Add fortnite-build-reset-devices-collection to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.

Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.

Comments

    Sign in to vote, comment, or suggest an edit. Sign in