Create Your First Verse Device Script

In this lesson you'll learn to

  • ✓Create a new Verse device file in UEFN using Verse Explorer.
  • ✓Write a Verse device script that uses a variable, a function, and an if/else check.
  • ✓Compile and drag your custom device into your Fortnite island level.
  • ✓Playtest your island and see your Verse code run live in the game.

🎮 What Is a Verse Device?

Imagine a remote control car. The car itself sits on the floor of your room — that's like your Fortnite island. The circuit board inside the car is the device. The instructions you program into it tell the car what to do: go forward, turn left, honk!

A Verse device works the same way. It's a little invisible gadget you place on your island. Your Verse code is the instructions inside it. When the game starts, the device follows your instructions and makes things happen!


🛠️ Step 1 — Create a New Verse Device File

First, you need to make the file where you'll write your code. Think of this like getting a blank piece of paper before you draw.

Here's how:

  1. Open your project in UEFN (Unreal Editor for Fortnite).
  2. In the top menu bar, click Verse, then click Verse Explorer. This is like a file cabinet for all your Verse scripts.
  3. In Verse Explorer, right-click your project name. Choose Add new Verse file to project.
  4. A window pops up. Click Verse Device as your template. A template is a starter design — like a cookie cutter that already has the basic shape.
  5. In the Device Name box, type score_tracker_device. Then click Create.
  6. Double-click your new file in Verse Explorer. It opens in Visual Studio Code — that's your coding notebook!

🧱 Step 2 — Understand the Starter Code

When UEFN creates your device file, it gives you some starter code. Here's what the important parts mean:

  • using { /Script/FortniteGame } — This line is like saying "borrow tools from Fortnite's toolbox."
  • creative_device — This is the special Verse type that makes your script become a real device on your island.
  • OnBegin — This is a built-in function. It runs your code the moment the game starts. Think of it like the starting pistol at a race — bang, your code goes!

🔢 Step 3 — Variables: Boxes That Hold Information

A variable is like a labeled box. You put something inside, and you can change what's in it later.

For example:

  • A box labeled PlayerScore might hold the number 0 at the start.
  • When a player does something cool, you change it to 1, then 2, and so on!

In Verse, you create a variable like this:

var Score : int = 0
  • var means "this box can change later."
  • Score is the label on the box.
  • int means the box holds a whole number (like 0, 1, 5 — no fractions).
  • = 0 is the starting value — the number already inside the box.

⚙️ Step 4 — Functions: Named Sets of Instructions

A function is like a recipe. You write it once, give it a name, and you can use it over and over.

Imagine a recipe called "Make Lemonade." Every time you follow it, you get lemonade! A function called AddPoint could say: every time you run it, add 1 to the score.


🔀 Step 5 — Control Flow: Making Decisions

Control flow means your code can make choices. Think of it like a Choose-Your-Own-Adventure book.

If something is true, do this. Else (otherwise), do that.

if (Score >= 3):
    Print("You win! 🎉")
else:
    Print("Keep going!")
  • if asks a question: Is Score 3 or more?
  • If YES, it prints "You win!"
  • If NO, it prints "Keep going!"

📦 Step 6 — Compile and Place Your Device

Compiling means turning your human-readable code into something UEFN can actually run. It's like a translator turning English into Robot Language.

  1. In the top menu, click Verse > Build Verse Code.
  2. Wait a moment. Your device now appears in the Content Browser under CreativeDevices.
  3. Drag and drop your device onto your island — just like placing any other object!
  4. Click Launch Session in the toolbar to playtest. Hit Start Game and watch your code run! 🚀

Worked Example

🏆 Worked Example: A Score-Tracking Device

The goal: Make a device that tracks a player's score. When the game starts, it gives the player points one at a time and announces when they win.

Place this code inside your device file in Visual Studio Code:

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

# This tells UEFN that our script is a real device for the island
score_tracker_device := class(creative_device):

    # A variable — like a labeled box — to hold the score.
    # "var" means we can change it later. It starts at 0.
    var Score : int = 0

    # OnBegin runs automatically the moment the game starts.
    # Think of it as the starting pistol for your code!
    OnBegin<override>()<suspends> : void =
        Print("Game started! Score = 0")  # Announce the start

        # Call our custom function to add a point
        AddPoint()
        AddPoint()
        AddPoint()  # Add three points, one at a time

    # This is our custom function — a recipe called "AddPoint"
    AddPoint() : void =
        set Score = Score + 1  # Open the box, add 1, put it back
        Print("Score is now: {Score}")  # Show the new score

        # Control flow: check if the player has won yet
        if (Score >= 3):
            Print("YOU WIN! Amazing job! 🎉")  # Score is 3 or more
        else:
            Print("Keep it up! Almost there!")  # Score is less than 3

📖 Walkthrough

Line What it does
score_tracker_device := class(creative_device) Says "this is a device that goes on the island"
var Score : int = 0 Creates a number box called Score, starting at 0
OnBegin<override>()<suspends> : void = This runs the moment the game starts
AddPoint() Runs our recipe/function to add one point
set Score = Score + 1 Opens the Score box and adds 1
if (Score >= 3) Asks: is Score 3 or bigger?
Print(...) Shows a message in the game log — great for testing!

🎮 What You'll See

When you playtest, check the Output Log in UEFN. You'll see messages like:

Game started! Score = 0
Score is now: 1
Keep it up! Almost there!
Score is now: 2
Keep it up! Almost there!
Score is now: 3
YOU WIN! Amazing job! 🎉

Your Verse code is running live inside your Fortnite island! How cool is that? 🌟

Try It Yourself

🎯 Your Turn: Build a Countdown Device!

You just saw a score go up. Now try making it go down — like a countdown!

Your mission:

  1. Create a new Verse device called countdown_device.
  2. Add a variable called TimeLeft that starts at 5.
  3. Write a function called Tick that subtracts 1 from TimeLeft each time it runs. (Hint: subtraction uses the - symbol!)
  4. Call Tick five times inside OnBegin.
  5. Use an if/else to check: if TimeLeft <= 0, print "Blast off! 🚀". Otherwise, print "Counting down: {TimeLeft}".
  6. Compile your code (Verse > Build Verse Code), drag it onto your island, and playtest!

🔑 Hints:

  • To subtract, use: set TimeLeft = TimeLeft - 1
  • The structure of your function will look very similar to AddPoint() — just change + to - and update the variable name and messages!
  • Remember: compile first, THEN drag it to the level!

Bonus challenge 🌟: Can you change the win condition so it prints a special message when TimeLeft reaches exactly 0?

🏴‍☠️

Take on the Challenge

Pass the 4-question challenge to master this lesson and chart the quest in your journal.

Recap

🌟 Great Work — Here's What You Learned!

Today you built your very first custom Verse device from scratch. You learned that a variable is like a labeled box that can hold changing information (like a score), and a function is a reusable recipe of instructions you can call by name. You used control flow (if/else) to make your device make smart decisions. Finally, you compiled your code and dropped your device onto your real Fortnite island — which means YOU just made something that runs live inside a game. That is seriously impressive! 🎉

Pass the quiz above to chart this quest in your Journal.

Sources

/docs/documentation/en-us/uefn/create-your-own-device-in-verse/docs/documentation/en-us/fortnite/create-your-own-device-in-verse/docs/documentation/en-us/fortnite/create-your-own-device-using-verse-in-unreal-editor-for-fortnite
Source

Biloxi Studios original lesson

Guided course

Add this lesson to your free study plan.

🧭 The Keeper’s log

Quest complete? Chart your next heading from the Verse Basics expedition.

⛵ Take me there