using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script. # It connects the coin to the reward. MyCollectibleScript := class(creative_device): # Bind MyCoin in the UEFN editor by selecting this device # and assigning the Collectible Object to this property. @editable MyCoin : collectible_object_device = collectible_object_device{} # Bind MyRewards in the UEFN editor by selecting this device # and assigning the Item Granter to this property. @editable MyRewards : item_granter_device = item_granter_device{} # This part runs when the game starts. OnBegin(): void= # We listen for when the coin is picked up. # 'MyCoin' must be assigned in your editor's Details panel. MyCoin.CollectedEvent.Subscribe(OnCoinPicked) Print("Coin is ready! Go get it!") # This function runs when the coin is picked. # CollectedEvent sends the agent (player) who picked it up. OnCoinPicked(Collector : agent): void= # Give the player their reward via the Item Granter. # The Item Granter device grants whichever item # you configured in its own Details panel in the editor. # Note: item_granter_device has no runtime item-name API; # set the item inside the device's settings in UEFN. MyRewards.GrantItem(Collector) Print("You got a Boogie Bomb!")