# LootGoblin.verse # This script makes a collectible object give rewards and update a score. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main device. Think of it as the brain attached to the Collectible Object. # creative_device is the correct base class for UEFN island scripting. LootGoblin := class(creative_device): # A reference to the Collectible Object device placed in the editor. # Drag your Collectible Object device into this slot in the Verse panel. @editable CollectibleDevice : collectible_object_device = collectible_object_device{} # 1. The Variable: A container for the player's score. # We start at 0. This is like an empty XP bar. # 'var' marks this as mutable so we can change it later. var PlayerScore : int = 0 # 2. The Setup: What happens when the game starts? OnBegin() : void = # Subscribe our handler to the collectible's CollectedEvent. # Every time a player picks up the collectible, OnPickup will run. CollectibleDevice.CollectedEvent.Subscribe(OnPickup) Print("Loot Goblin is awake. Go get those gems!") # 3. The Event Handler: called automatically when CollectedEvent fires. # CollectedEvent passes the agent (player) who triggered the pickup. OnPickup(Agent : agent) : void = # Update the score variable. set PlayerScore += 10 # Tell the game what happened. Print("A gem was grabbed! Score is now {PlayerScore}") # Reward message (see the Pro Version below for the real Item Granter call). Print("Reward: You found an Assault Rifle!") # Optional: The Collectible Object resets based on its own device settings # configured in the UEFN editor (e.g., respawn timer).