# This is our main script. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } # This is our Scoreboard script. Scoreboard := class(creative_device): # This is the button we dragged into the island. # We connect it in the editor. @editable ClickButton: button_device = button_device{} # This is the HUD Controller. # It is the tool that talks to the screen. # @editable means we can see it in the editor. @editable MyHUD: hud_controller_device = hud_controller_device{} # This is our variable. # It is a box for our score. # It starts at zero. # var means we can change it later. var CurrentScore: int = 0 # This function runs when the game starts. OnBegin(): void = # We connect our button to a function. # When the button is clicked, run this code. # Note: button_device.InteractedWithEvent passes the agent who clicked. ClickButton.InteractedWithEvent.Subscribe(OnButtonClicked) # This function runs when the button is clicked. # It receives the agent (player) who clicked the button. OnButtonClicked(Agent: agent): void = # First, we change the score. # We add one to the current score. set CurrentScore += 1 # Now we tell the HUD to update. # We pass the agent and the new score to the HUD. # Note: hud_controller_device.UpdateAffectedClass sets the affected class on the HUD. MyHUD.UpdateAffectedClass(Agent) # We also print it to the debug log. # This helps us see if it works. Print("Score is now: {CurrentScore}")