Scoreboard Shenanigans: Building a Scoring System in Verse
Tutorial beginner

Scoreboard Shenanigans: Building a Scoring System in Verse

Updated beginner

Scoreboard Shenanigans: Building a Scoring System in Verse

So you want to know who’s the king of the hill, the fastest racer, or the ultimate loot goblin? You can’t just guess—it needs a scoreboard. In Fortnite Creative, we used to wire up a messy spiderweb of cables to make numbers go up. In Verse, we write code that acts like a referee, keeping track of points behind the scenes and updating the UI when it matters.

In this tutorial, we’re going to build a "Loot Goblin" system. Players will pick up crates to earn points, and we’ll use Verse to track those points and display them on the screen. No more broken wires, no more magic numbers. Just clean, functional code that keeps score.

What You'll Learn

  • Variables: How to store a changing number (like your current score) in memory.
  • Functions: How to create reusable blocks of code that handle logic (like "add points" or "update screen").
  • The Score Manager Device: How to connect your Verse code to Fortnite’s built-in UI devices.
  • Scene Graph Basics: Understanding how your code lives inside a device in the editor.

How It Works

Think of a scoring system like a video game’s internal memory. When you pick up a shield potion, your shield bar goes up. That bar isn’t a physical object you can throw; it’s a number stored in the game’s memory that tells the UI what to draw.

In Verse, we use variables to store these numbers. A variable is like a labeled box. You can put a number in it, take it out, or change what’s inside. If your score is 0, you put 0 in the "Score" box. If you kill a bot, you take the 0 out, add 100, and put 100 back in the box.

But storing the number isn’t enough. You need a way to update the screen. This is where functions come in. A function is like a button on a remote control. You press "Volume Up," and the TV increases the volume. You don’t need to know how the TV works internally; you just call the function. We’ll create functions like AddPoints() and UpdateUI().

Finally, we need to talk to the Score Manager device. This is a Fortnite Creative device that handles the heavy lifting of displaying scores on the screen. Our Verse code will act as the brain, deciding when to tell the Score Manager to update, and what number to show it.

Let's Build It

We are building a simple "Pick-Up Points" system.

  1. Place a Score Manager Device in your world.
  2. Create a Verse Device (let's call it LootGoblinScore).
  3. Write the code to track points and update the UI.

The Verse Code

Copy this into your Verse file. I’ve added comments to explain what each part does, using game mechanics you already know.

# This is a "Device" in Verse. Think of it as a custom gadget you place in the world.
# It’s like a Race Manager, but instead of timing laps, it tracks loot points.
LootGoblinScore: device =
    # --- VARIABLES (The "Boxes" for our data) ---
    
    # TotalScore is like your current XP bar. It changes constantly.
    # We start it at 0.
    var TotalScore: int = 0
    
    # PendingScore is like a "cart" before you check out.
    # We add points here first, then dump them into TotalScore later.
    # This prevents glitches if multiple things happen at once.
    var PendingScore: int = 0
    
    # This is a reference to the Score Manager device in the editor.
    # We need to link this in the editor later!
    ScoreManagerDevice: score_manager_device = score_manager_device{}
    
    # This is the text box on the screen.
    # We’ll use this to show the player their score.
    ScoreText: text_block = text_block{}
    
    # --- FUNCTIONS (The "Buttons" for logic) ---
    
    # This function adds points to the "cart" (PendingScore).
    # Imagine picking up a crate. You don't update the screen immediately.
    # You just add it to your pocket.
    AddPoints<public>(Points: int) : void =
        PendingScore += Points
        # We call UpdateUI to refresh the screen.
        # "defer" means "do this after everything else in this frame is done."
        # It’s like waiting for the storm to finish shrinking before you check your HP.
        defer:
            UpdateUI()
    
    # This function moves points from the "cart" to the "bank" (TotalScore).
    # It also updates the visual text on the screen.
    UpdateUI<public>() : void =
        # Move pending points to total score.
        TotalScore += PendingScore
        # Reset the cart to 0 for the next pickup.
        PendingScore = 0
        
        # Now, tell the Score Manager device to update its value.
        # SetScoreAward sets the number the device knows about.
        ScoreManagerDevice.SetScoreAward(TotalScore)
        
        # Update the text block on the screen.
        # We convert the integer (number) to a string (text) to display it.
        ScoreText.SetContent($"{TotalScore}")
        
        # Finally, activate the Score Manager to show the UI to the player.
        # This is like pressing "Show Scoreboard" on the gamepad.
        ScoreManagerDevice.Activate()

    # --- EVENT HANDLERS (What happens when stuff triggers) ---
    
    # This event runs when the device starts.
    # It’s like when the bus drops you off and the game begins.
    OnBegin<override>()<suspends>: void =
        # Initialize the text block to show "0" at the start.
        ScoreText.SetContent("0")
        # Activate the UI so the player sees it immediately.
        ScoreManagerDevice.Activate()

Walkthrough: What Just Happened?

  1. var TotalScore: int = 0: We created a variable named TotalScore. It’s an int (integer, or whole number). It starts at 0. This is your main score.
  2. AddPoints<public>(Points: int) : void: This is a function. <public> means other devices can call this function. If you have a "Loot Crate" device, it can call LootGoblinScore.AddPoints(10) to give you 10 points.
  3. defer:: This is crucial. In Verse, defer means "wait until the end of this frame." Why? Because if you update the UI while the game is still calculating physics, you might get a flickering screen. It’s like waiting for the building edit to finish before you shoot.
  4. ScoreManagerDevice.SetScoreAward(TotalScore): This line connects your Verse code to the Fortnite device. You’re telling the Score Manager, "Hey, update your internal value to whatever TotalScore is right now."
  5. ScoreText.SetContent($"{TotalScore}"): This updates the actual text on the screen. The $ symbol converts the number into text so it can be displayed.

Try It Yourself

Now that you have the basic code, here’s your challenge:

The Challenge: Add a "Penalty" function.

Create a new function called ApplyPenalty(PenaltyPoints: int) that subtracts points from PendingScore. If PendingScore goes below zero, make sure it stays at zero (no negative scores allowed!).

Hint: Use an if statement to check if PendingScore is less than 0. If it is, set PendingScore to 0. Then call UpdateUI().

Recap

  • Variables are like boxes that store changing data (your score).
  • Functions are like buttons that perform actions (adding points, updating UI).
  • defer: ensures your UI updates happen cleanly at the end of the frame, avoiding glitches.
  • Score Manager is the Fortnite device that actually displays the numbers on screen; your Verse code tells it what to show.

You now have a working scoring system. You can add more crates, more penalties, or even different point values for different items. The sky’s the limit—just make sure your code doesn’t crash the server.

References

  • https://dev.epicgames.com/documentation/en-us/uefn/car-racing-4-add-scoring-system-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite/pizza-pursuit-4-managing-and-displaying-the-score-for-time-trial-in-verse
  • https://dev.epicgames.com/documentation/en-us/fortnite/car-racing-4-add-a-scoring-system-in-unreal-editor-for-fortnite
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/top-scorer-in-class-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/uefn/pizza-pursuit-4-managing-and-displaying-the-score-in-verse

Get the complete code — free

You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.

Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.

Verse source files

Turn this into a guided course

Add 4. Add a Scoring System 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