# This is a Verse script for a grenade dispenser.
# It gives a player a grenade when they use a device.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# This is our main script block.
# It holds all the code for our dispenser.
grenade_dispenser := class(creative_device):
# 'ItemGranter' is a item_granter_device placed in your scene.
# Connect it in the UEFN editor's details panel.
# note: Verse has no direct GiveItem() API on player; item_granter_device is the correct way to grant items.
@editable
ItemGranter : item_granter_device = item_granter_device{}
# OnBegin runs when the island starts.
# We subscribe to the item granter's activation here.
OnBegin<override>()<suspends> : void =
# We print a message to the console.
# This helps us know the device started correctly.
Print("Grenade dispenser is ready!")
# This function is called by a button_device or switch
# wired to this device via the UEFN event binding panel.
# 'Agent' is the person who flipped the switch.
OnPlayerUsed(Agent : agent) : void =
# We tell the item granter to give its configured item to the agent.
Verse Library
verse
01 Device
Wires a creative button device to an item granter, delivering configured items to activating players.
verse-library/using-grenade-items-in-fortnite-creative/01-device.verse
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.