How to Give Players Their Prize: Configuring Rewards
Tutorial beginner compiles

How to Give Players Their Prize: Configuring Rewards

Updated beginner Code verified

How to Give Players Their Prize: Configuring Rewards

Imagine you just finished a hard level in a video game. Did you get a badge? Did you find gold? Did you unlock a new power?

Rewards make games fun. They give players a reason to keep playing. In Fortnite Creative, we can build our own reward system.

We will build a simple "Treasure Hunt." Players will find a secret spot. When they find it, they get Gold. They also get a message on their screen.

Let's make something playable!

What You'll Learn

  • How to give players items using an Item Granter.
  • How to show text on the screen using a HUD Message.
  • How to connect devices so they work together.
  • How to make different messages for winning or losing.

How It Works

Think of your island like a stage in a play. Every device is an actor.

  1. The Item Granter is like a magic vending machine. It holds items. When you press the right button, it gives you something. We will use it to give out Gold. Gold is a special currency in Creative.
  2. The HUD Message is like a speech bubble. HUD stands for "Heads-Up Display." It shows text on the player's screen. It does not move with the camera. It stays fixed.

We need to link them. We use Events. An event is like a domino falling. One thing happens, and it pushes the next thing.

When a player steps on a trigger, the trigger tells the Item Granter to give Gold. Then, the trigger tells the HUD Message to say "Good Job!"

Let's Build It

First, place your devices in the World Editor.

  1. Place an Item Granter.
  2. Place a HUD Message device.
  3. Place a Trigger Volume (this is the "secret spot").

Now, we write the Verse code. This code tells the devices what to do.

Here is the code for our Treasure Hunt.

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

# This is our main script. It controls the rewards.
treasure_hunt := class(creative_device):
    # This is the Item Granter. It holds the Gold.
    @editable
    ItemGranter : item_granter_device = item_granter_device{}

    # This is the HUD Message. It shows text.
    @editable
    HudMessage : hud_message_device = hud_message_device{}

    # This is the Trigger. It watches for players.
    @editable
    Trigger : trigger_device = trigger_device{}

    # This runs when the game starts.
    OnBegin<override>()<suspends> : void =
        # Connect the trigger to our reward logic.
        # When the trigger fires, run GiveReward.
        Trigger.TriggeredEvent.Subscribe(GiveReward)

    # This function gives the reward.
    GiveReward(Agent : ?agent) : void =
        # 1. Grant items via the Item Granter device.
        # The item_granter_device is pre-configured in the World Editor
        # with the item and quantity you want to give (e.g. 10 Gold).
        # GrantRandomItem gives the next item the device is holding.
        # note: item_granter_device has no runtime quantity API; set the
        # item and stack size in the device's properties panel instead.
        if (A := Agent?):
            ItemGranter.GrantItem(A)

            # 2. Show a message on the screen.
            # We use the HUD Message device.
            HudMessage.Show(A)```

### Walkthrough of the Code

*   **`ItemGranter`**: We create a variable for the Item Granter. The `@editable` tag lets you link this variable to the actual device in the World Editor.
*   **`GrantItem`**: This is a command. It tells the granter to give the item it is holding to a specific player. Set the item and quantity inside the device's properties panel in the World Editor.
*   **`Show`**: This command makes the text appear for a specific player. Set the message text inside the HUD Message device's properties panel.
*   **`TriggeredEvent`**: This is the link. It says "When the trigger is hit, run this code."

### Making It More Fun

You can have different rewards!

If the player finds the treasure, they get Gold.
If they miss the treasure, they get nothing.

You can add a second HUD Message. Call it `FailMessage`. Use `Show` on it if they do not find the spot in time. This teaches players to try again.

## Try It Yourself

Can you make a "Shop"?

1.  Place an **Item Granter** and put a **Jewel** in it.
2.  Place a **Conditional Button**.
3.  Set the button to cost **50 Gold**.
4.  When the player clicks the button, they spend 50 Gold and get the Jewel.

**Hint:** Look at the **Conditional Button** properties. It has a spot for "Key Items Required." Set that to Gold. Then connect its "On Interact" event to the Item Granter.

Did it work? Great job! You just built a shop.

## Recap

*   **Item Granter** gives items to players.
*   **HUD Message** shows text on the screen.
*   **Events** connect devices together.
*   You can make rewards for winning, losing, or buying.

Keep building! Your island is only limited by your imagination.

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/stat-counter-design-examples-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/stat-counter-design-examples-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/prop-manipulator-device-design-examples-in-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/inisland-transactions-device-template-in-fortnite
*   https://dev.epicgames.com/documentation/en-us/fortnite/creating-items-and-offers-in-fortnite

Verse source files

Turn this into a guided course

Add Configure the Rewards 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