# ScoreManager.verse # This script tracks team scores and updates the UI. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } # Define our main device. This is the "Container" for our logic. # Think of it like a Prop Mover device, but instead of moving props, it moves data. ScoreDevice := class(creative_device): # A reference to the Score Manager device placed in the level. # Wire this up in the UEFN editor to the Score Manager device for Team 1. @editable RedScoreManager : score_manager_device = score_manager_device{} # Wire this up in the UEFN editor to the Score Manager device for Team 2. @editable BlueScoreManager : score_manager_device = score_manager_device{} # A reference to the two Trigger devices placed in the level. # Wire RedTrigger to the Team 1 capture zone trigger in the editor. @editable RedTrigger : trigger_device = trigger_device{} # Wire BlueTrigger to the Team 2 capture zone trigger in the editor. @editable BlueTrigger : trigger_device = trigger_device{} # VARIABLES: These are our "Scoreboards." # They start at 0 and change as players touch the zone. # In Verse, we use 'var' for things that change, and 'const' for things that stay the same. var RedScore : int = 0 var BlueScore : int = 0 # OnBegin runs once when the game session starts. # It's like the "On Game Start" event in a standard Creative device. OnBegin() : void = # Subscribe to each trigger's TriggeredEvent so we know when a player enters the zone. RedTrigger.TriggeredEvent.Subscribe(OnRedZoneEntered) BlueTrigger.TriggeredEvent.Subscribe(OnBlueZoneEntered) # Called whenever a player steps into the Red capture zone. OnRedZoneEntered(Player : ?agent) : void = set RedScore += 1 # Award the point through the Score Manager device wired to Team 1. # score_manager_device.Activate() grants the score value configured on the device. if (LivePlayer := Player?): RedScoreManager.Activate(LivePlayer) # Called whenever a player steps into the Blue capture zone. OnBlueZoneEntered(Player : ?agent) : void = set BlueScore += 1 # Award the point through the Score Manager device wired to Team 2. if (LivePlayer := Player?): BlueScoreManager.Activate(LivePlayer)