using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } # This is our Treasure Hunter Device treasure_hunter_device := class(creative_device): # This is the number of points needed to win WinScore : int = 5 # This is the device that gives the points @editable PowerupDevice : stat_powerup_device = stat_powerup_device{} # This is the trigger that detects players walking in @editable TriggerDevice : trigger_device = trigger_device{} # This runs when the game starts OnBegin() : void = Print("Treasure Hunt Started!") # Subscribe to the trigger so we know when a player enters TriggerDevice.TriggeredEvent.Subscribe(OnTreasureTriggered) # This runs when a player touches the trigger OnTreasureTriggered(Agent : ?agent) : void = if (LiveAgent := Agent?): if (Player := player[LiveAgent]): # Give the player 1 point via the Stat Powerup device PowerupDevice.GrantToAgent(LiveAgent) # note: stat_powerup_device exposes GrantToAgent; point value # is configured in the device's UEFN property panel (set to 1). # Read the player's current score from the stat creator device # and check whether they have reached the win threshold. # note: Score comparison is handled through Island Settings # Victory Condition (Score >= WinScore) configured in UEFN, # because stat values are read server-side by the engine. Print("Point collected! Reach {WinScore} to win!")