# This is our main script file. # It connects the button to the spawner. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We declare our device class, which holds references # to the devices we placed in the editor. monster_squad_device := class(creative_device): # These @editable fields let us drag our placed # devices into the script from the UEFN Details panel. @editable CreatureSpawner : creature_spawner_device = creature_spawner_device{} @editable Button : button_device = button_device{} # OnBegin runs automatically when the game starts. # We use it to connect the Button to our function. OnBegin() : void = # Now we connect the Button to the function. # When the button is pressed, we run StartSpawning. Button.InteractedWithEvent.Subscribe(StartSpawning) # We define a function called StartSpawning. # A function is a reusable block of code. # It receives the agent (player) who pressed the button. StartSpawning(Agent : agent) : void = # This line tells the spawner to begin. # We use the spawner's Enable method to start it. CreatureSpawner.Enable() # We also print a message to the console. # This helps us know it worked. Print("Monsters are coming!")