# This is a comment. It helps us remember what the code does. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We define our scorekeeper as a Verse device so it can # live on the island and talk to other UEFN devices. scorekeeper_device := class(creative_device): # Drag your Trigger Volume here in the UEFN Details panel. @editable MyTrigger : trigger_device = trigger_device{} # Drag your HUD Message Device here in the UEFN Details panel. # hud_message_device shows text on screen for a player. # Replace this with your actual device reference. @editable MyHUD : hud_message_device = hud_message_device{} # We create a variable named 'Score'. # It starts at 0. It is an integer (a whole number). # 'var' means the value is allowed to change. var Score : int = 0 # OnBegin runs automatically when the game starts. OnBegin() : void = # We tell the trigger to call our function # whenever a player enters it. MyTrigger.TriggeredEvent.Subscribe(OnPlayerEntered) # This function runs when a player enters the trigger. # 'Agent' is the person who stepped on the plate. OnPlayerEntered(Agent : ?agent) : void = # We add 1 to the current Score. set Score = Score + 1 # We convert the number to text. # Computers need text to show words on screen. ScoreText := "Score: {Score}" # We update the HUD Message device. # Show() displays the message panel for every player. # note: hud_message_device is the standard way to display # dynamic text strings to players in UEFN Verse. MyHUD.Show()