Verse Library verse

01 Fragment

Grants a random item from a predefined loot table when players interact with the device.

verse-library/using-flopper-items-in-fortnite-creative/01-fragment.verse

# ChaosChestScript.v
# A device that grants random Flopper items to players who interact with it.

# 1. DEFINE THE DEVICE
# We tell Verse this script belongs to a specific device instance.
# Think of this as labeling the box "DO NOT OPEN" in permanent marker.
actor ChaosChestDevice : public Device = {
    # This is the "Event" that fires when a player interacts.
    # It's like the storm timer ticking down—it happens at a specific moment.
    OnInteract<override>(player: Player, _device: Device) -> void = {
        # 2. PICK A RANDOM FLOPPER
        # We create a list of possible items (the loot table).
        # In Verse, we use a "List" to hold multiple items.
        flopper_options := {
            ItemData.Snowy_Flopper,
            ItemData.Flopper,
            ItemData.Shadow_Flopper,
            ItemData.Hop_Flopper,
            ItemData.Vendetta_Flopper,
            ItemData.Midas_Flopper
        }

        # 3. ROLL THE DICE
        # We pick one item from the list at random.
        # This is like the random spawn location of a vehicle.
        selected_item := flopper_options[RandomInt(len(flopper_options))]

        # 4. GIVE THE ITEM TO THE PLAYER
        # We need to access the player's inventory.
        # The Inventory is a "Component" attached to the Player entity.

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in