UEFN Verse: Award Player Score and Show It On-Screen
Tutorial intermediate compiles

UEFN Verse: Award Player Score and Show It On-Screen

Updated intermediate Code verified

What you'll learn

By the end of this guide you'll be able to:

  • Reference a score_manager_device and a button_device with @editable fields
  • Award points to a specific agent using Activate(Agent) (the CURRENT method — there is no Award on the score manager)
  • Read a player's live score with GetCurrentScore(Agent)
  • Build a text_block widget and push it to a player's HUD with GetPlayerUI[] and AddWidget
  • React to the manager's own ScoreOutputEvent so the UI refreshes exactly when points land

How it works

The score_manager_device owns all the scoring math. Two important corrections over the old approach:

  1. There is no Award[Player] method. The grounded signature exposes Activate() and Activate(Agent: agent). To grant points to one player you call ScoreManager.Activate(Player) — with parentheses, because it returns void and is not a <decides> function. Use SetScoreAward(Value) first to control how many points a single activation grants.

  2. GetPlayerUI and GetCurrentScore are fallible/transacting. GetPlayerUI is declared <transacts><decides>, so it MUST be called with [] inside a failure context such as an if. GetCurrentScore(Agent) is <transacts> and returns an int, so call it with parentheses and just read the value.

The flow: a player interacts with the button → we set the award amount and Activate the manager for that player → the manager fires ScoreOutputEvent → our handler reads the new score and adds (or updates) a text_block on that player's HUD.

Let's build it

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

# Awards points to the interacting player and shows their live score on the HUD.
score_awarder := class<concrete>(creative_device):

    # The Score Manager that owns the scoring logic.
    @editable ScoreManager : score_manager_device = score_manager_device{}

    # Button players interact with to earn points.
    @editable TriggerButton : button_device = button_device{}

    # How many points each button press grants.
    @editable PointsToAward : int = 10

    # Tracks the text widget we created per player so we can update instead of stacking new ones.
    var ScoreWidgets : [player]text_block = map{}

    OnBegin<override>()<suspends> : void =
        # Button press awards points; manager confirms via ScoreOutputEvent, which drives the UI.
        TriggerButton.InteractedWithEvent.Subscribe(OnButtonPressed)
        ScoreManager.ScoreOutputEvent.Subscribe(OnScoreAwarded)
        Print("Score Awarder ready.")

    # Runs when a player interacts with the button.
    OnButtonPressed(Agent : agent) : void =
        # Configure how much the next activation grants, then award to THIS agent (parens: returns void).
        ScoreManager.SetScoreAward(PointsToAward)
        ScoreManager.Activate(Agent)

    # Runs when the manager confirms points were awarded to an agent.
    OnScoreAwarded(Agent : agent) : void =
        # GetCurrentScore is <transacts> and returns an int - call with parens, read directly.
        NewScore := ScoreManager.GetCurrentScore(Agent)
        # player is a subtype of agent; narrow it so we can use it as a HUD/map key.
        if (Player := player[Agent]):
            ShowScore(Player, NewScore)

    # Adds a fresh text_block to the player's HUD, or updates the existing one.
    ShowScore(Player : player, Score : int) : void =
        ScoreText := TextToDisplay(Score)
        if (Existing := ScoreWidgets[Player]):
            # Reuse the widget already on screen - just refresh its text.
            Existing.SetText(ScoreText)
        else if (PlayerUI := GetPlayerUI[Player]):
            # No widget yet: build one, remember it, and add it to this player's HUD.
            NewText := text_block{DefaultText := ScoreText}
            if (set ScoreWidgets[Player] = NewText):
                PlayerUI.AddWidget(NewText)

    # Builds the on-screen message from the current score.
    TextToDisplay<localizes>(Score : int) : message = "Score: {Score}"

Try it yourself

  1. Place a Score Manager device, a Button device, and your Verse-authored score_awarder device on the island.
  2. On the Score Manager, set Score Award Type to Add so activations accumulate.
  3. Select the Verse device and assign the Score Manager to ScoreManager and the button to TriggerButton.
  4. Adjust PointsToAward in the Details panel (default 10) to taste.
  5. Launch a session, walk up to the button, and interact. Watch the score readout appear on your HUD and climb with every press.

Recap

  • Grant points with ScoreManager.Activate(Agent) — parentheses, because it returns void; there is no Award method on the score manager.
  • Use SetScoreAward(Value) to set how many points a single activation awards.
  • GetCurrentScore(Agent) is <transacts> and returns an int; call it with parens and read the result.
  • GetPlayerUI[Player] is <transacts><decides> — always call it with [] inside an if.
  • Build a text_block, keep it in a [player]text_block map, and reuse it via SetText so widgets don't stack up.
  • ScoreOutputEvent fires when the manager actually awards points, giving you a reliable moment to refresh the HUD.

Check your understanding

Test yourself with an interactive quiz and track your progress + earn XP — free for members.

Turn this into a guided course

Add Awarding Player Score via Score Manager Device 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