Spooky Power-Ups: Making Halloween Candy in Fortnite
Tutorial beginner compiles

Spooky Power-Ups: Making Halloween Candy in Fortnite

Updated beginner Code verified

Spooky Power-Ups: Making Halloween Candy in Fortnite

Do you want to make your island feel like a real Halloween party? You can add special items that give players superpowers! We will build a "Candy Corner." It is a place where players find treats. These treats heal them or make them jump higher. It is like magic, but it is made with code. Let's make some spooky snacks.

What You'll Learn

  • How to use the Item Granter device.
  • What Halloween Candy items do.
  • How to give players a temporary boost.
  • How to place items so players can find them.

How It Works

Think of an Item Granter like a vending machine. You put a snack inside. A player walks up. The machine gives them the snack. In Fortnite, we use these for special items.

There are five types of Halloween Candy. They are all consumables. This means they are used up when a player eats them. Each one gives a different boost.

  • Candy Corn: Gives health back. It is like a bandage.
  • Hop Drop: Makes you jump higher. It is like bunny feet.
  • Jelly Bean: Makes you move faster. It is like running on ice.
  • Peppermint: Gives you a shield. It is like a bubble of protection.
  • Thermal Taffy: Makes you see better in the dark. It is like a flashlight.

We will use code to tell the Item Granter which candy to give. We will also make it reset. This means it gives candy again after a player takes it. This way, the game never runs out of treats!

Let's Build It

First, open Fortnite Creative. Go to the Device tab. Look for Item Granter. Place it on the ground. Next, find a Trigger device. Place it near the granter. This trigger will tell the code when to give candy.

Now, let's write some Verse. This code connects the trigger to the granter. It picks a random candy. It gives it to the player.

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

# This is our main script block
SpookyCandyDevice := class(creative_device):

    # This is the Item Granter device
    # We connect it in the editor
    @editable
    CandyMachine : item_granter_device = item_granter_device{}

    # This is the Trigger device
    # We connect it in the editor
    @editable
    PlayerTrigger : trigger_device = trigger_device{}

    # This is the list of all candies
    # Each entry is an item_granter_device set up in the editor
    # to grant a specific candy type via its Item setting
    # note: Verse has no built-in candy item enum; candy type is
    # configured per-device in the editor, so we use one
    # item_granter_device per candy and pick among them randomly.
    @editable
    CandyGranters : []item_granter_device = array{}

    # OnBegin runs once when the game starts
    OnBegin<override>()<suspends> : void =
        # Subscribe to the trigger's agent-enters event
        PlayerTrigger.TriggeredEvent.Subscribe(OnEnter)

    # This function runs when a player enters the trigger
    OnEnter(Instigator : ?agent) : void =
        # Make sure we have at least one granter configured
        if (CandyGranters.Length > 0):
            # Pick a random index from the list
            RandomIndex := GetRandomInt(0, CandyGranters.Length - 1)
            # Look up the chosen granter; bracket access is failable
            if (SelectedGranter := CandyGranters[RandomIndex]):
                # Give the candy to the triggering agent if present
                if (TheAgent := Instigator?):
                    SelectedGranter.GrantItem(TheAgent)```

### Walkthrough of the Code

1.  **`using { ... }`**: This tells Verse what tools we need. We need Fortnite devices and Verse basics.
2.  **`CandyMachine`**: This is a **variable**. It holds the Item Granter. You must link the actual device in the editor to this name.
3.  **`CandyGranters`**: This is a **list**. Think of it like a menu. It has five slots. Each slot is a separate Item Granter device. You set each one to a different candy type in the editor. We use **`@editable`** so you can fill the list right inside the editor.
4.  **`OnBegin`**: This is the **startup function**. It runs once when the game starts. It connects the trigger to our `OnEnter` function using `Subscribe`.
5.  **`OnEnter`**: This is an **event handler**. It runs when a player steps on the trigger.
6.  **`GetRandomInt`**: This picks a random number. It chooses one candy granter from the menu.
7.  **`GrantItem`**: This is a **function**. It is an action. It gives the item to the player.

### Setting Up the Editor

1.  Place **five Item Granter** devices, one for each candy type. In each device's details panel, set its **Item** to the matching candy: Candy Corn, Hop Drop, Jelly Bean, Peppermint, or Thermal Taffy.
2.  Place a **Trigger** device. Make it big enough for a player to walk into.
3.  Select your **SpookyCandyDevice** actor. In the Verse/editable section, add all five Item Granter devices to the `CandyGranters` array in order.
4.  Also link the **Trigger** device to `PlayerTrigger` in the same section.
5.  Set the Trigger device to **Re-trigger Delay** of a few seconds in its settings. This lets players come back for more candy without spamming the trigger.

## Try It Yourself

Can you make the candy give a shield instead of health?

**Hint:** Look at the `CandyGranters` list. Try putting the **Peppermint** Item Granter first in the array. Then change `GetRandomInt` to always return `0`. Test your island. See if the player gets a shield bubble!

## Recap

You made a spooky candy machine! You used an **Item Granter** to give items. You used a **Trigger** device to detect players. You used a **list** to pick random candy granters. This is a simple way to add fun power-ups. Try adding more triggers for different candies. Have fun creating!

## References

*   https://dev.epicgames.com/documentation/en-us/fortnite/using-halloween-candy-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-halloween-candy-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-halloween-candy-consumables-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-items-in-fortnite-creative
*   https://dev.epicgames.com/documentation/en-us/fortnite/using-items-in-fortnite-creative

Verse source files

Turn this into a guided course

Add using-halloween-candy-items-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