Build Your Own LEGO Treasure Hunt
Tutorial beginner compiles

Build Your Own LEGO Treasure Hunt

Updated beginner Code verified

Build Your Own LEGO Treasure Hunt

Do you like finding hidden treasures? Do you love building with LEGOs? Today, you will make a game where players collect shiny LEGO studs. These studs are like gold coins. They can unlock doors or give players cool items. You will learn how to make a treasure hunt that feels like a real LEGO movie. Let's start building!

What You'll Learn

  • What a Collectible Device is.
  • How to place it in your game world.
  • How to make other things happen when a player picks up a stud.
  • How to connect devices together.

How It Works

Imagine you are playing a video game. You walk into a room. On the floor, there is a shiny golden brick. You walk over it. Ding! You now have a point. That is what a Collectible Device does.

A Collectible Device is a special tool in Fortnite Creative. It creates an item that players can pick up. When they pick it up, it disappears. Then, it can do something else. It can play a sound. It can open a door. It can give a player a weapon.

Think of it like a vending machine. You put a coin in (pick up the stud). The machine gives you a snack (the reward). The device is the machine. The stud is the coin. The snack is the reward.

In LEGO islands, these are called LEGO Collectibles. They look like little LEGO studs. They are fun to collect. They make the game feel rewarding. You can have many of them in one game. You can hide them in trees. You can put them behind traps. You can make the player work for them.

Let's Build It

We will build a simple room. There is a locked door. There is a golden stud on a table. When the player picks up the stud, the door opens.

Here is how we do it step-by-step.

Step 1: Place the Door

  1. Open your island in UEFN.
  2. Go to the Content Drawer.
  3. Find the Door device.
  4. Place it in your room.
  5. Set the door to Locked at the start.

Step 2: Place the Collectible

  1. Go to the Content Drawer.
  2. Find LEGO Content.
  3. Find Devices.
  4. Select LEGO Collectible.
  5. Place it on a table near the door.
  6. Change its color to Gold.

Step 3: Connect Them (The Logic)

This is the magic part. We need to tell the door to open when the stud is taken.

  1. Click on the LEGO Collectible device.
  2. Look at the Properties panel.
  3. Find the On Collect event. This is an Event. An event is something that happens in the game. Like a bell ringing.
  4. Click the plus (+) button next to On Collect.
  5. A new box appears. This is an Action. An action is something the game does.
  6. Select Set Door State.
  7. Choose Open from the list.

Now, the door knows what to do. It waits for the collectible to be taken. Then it opens.

Step 4: Test It

  1. Click Play in the top right.
  2. Walk to the table.
  3. Pick up the golden stud.
  4. Watch the door swing open!
  5. You did it! You made a puzzle.

Code Example

In Fortnite Creative, we often use visual nodes instead of typing code. But here is how it looks if we wrote it in Verse. Verse is a programming language. It tells the computer exactly what to do.

# This is a simple Verse script
# It connects a collectible to a door

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# Our main game class wires the two devices together.
# In UEFN, set my_door and my_stud in the Details panel
# by tagging the placed devices with these property names.
treasure_hunt_manager := class(creative_device):

    # 1. Reference to the door device placed in the world
    @editable
    my_door : conditional_button_device = conditional_button_device{}

    # 2. Reference to the LEGO collectible device placed in the world
    @editable
    my_stud : collectible_object_device = collectible_object_device{}

    # OnBegin runs once when the game starts
    OnBegin<override>()<suspends> : void =
        # 3. Create the link
        # When the stud is collected...
        my_stud.CollectedEvent.Subscribe(OnStudCollected)

    # ...open the door!
    OnStudCollected(Agent : agent) : void =
        # Activate the conditional_button_device, which triggers
        # whatever action is wired to it in the Details panel
        # (set that action to "Unlock / Open" the door device).
        my_door.Activate(Agent)
        # note: door_device does not expose a direct Open() API in
        # Verse; the recommended pattern is to wire the door's
        # "Unlocked" input to this device's output in the Details
        # panel, or use a mutator_zone_device / switch_device as
        # the intermediary trigger.

Let's look at the code.

  • my_door is a name for our door.
  • my_stud is a name for our golden brick.
  • CollectedEvent is the event. It waits for a player to touch the stud.
  • Subscribe(OnStudCollected) is the link. It calls our function the moment the stud is picked up.
  • Activate is the action. It triggers the door to change from locked to open.

It is like giving instructions to a robot. "When you see the gold brick, open the door."

Try It Yourself

Now it is your turn to be creative!

Challenge: Add a second reward. When the player picks up the stud, make a sound play too.

Hint:

  1. Go back to the LEGO Collectible device.
  2. Click the plus (+) next to On Collect again.
  3. Look for a device that plays sound.
  4. Try adding a Sound action.
  5. Pick a fun sound from the list.

Can you make the door open AND play a happy tune?

Recap

You learned how to use LEGO Collectible Devices.

  • A Collectible is an item players can pick up.
  • An Event is when something happens (like picking up the item).
  • An Action is what happens next (like opening a door).
  • You can connect them to make puzzles and rewards.

Great job! You built a working game mechanic. Keep experimenting. Hide more studs. Make harder puzzles. Have fun creating!

References

  • https://dev.epicgames.com/documentation/en-us/fortnite/using-lego-collectible-devices-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/working-with-lego-islands-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/working-with-lego-islands-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite/lego-asset-inventory-in-fortnite-creative
  • https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-collectible-object-devices-in-fortnite-creative

Verse source files

Turn this into a guided course

Add using-lego-collectible-devices-in-fortnite-creative 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