# This script attaches to the End Game device. # It tells the End Game device: "Listen to the Timer. When it finishes, YOU stop the game." using { /Fortnite.com/Devices } end_game_device: EndGameDevice = EndGameDevice{} # This is the "Event Handler." # Think of it as a trap trigger. # We are listening for the timer's "OnTimerEnd" event. on_timer_finished(timer: TimerDevice) -> unit: # When the timer hits zero, this code runs. # We call the EndGame() function on our End Game device. end_game_device.EndGame() # This is the "Setup" function. # It runs once when the island starts. init() -> unit: # 1. Find the Timer device in the scene graph. # We assume we have a reference to the Timer. # In a real setup, you might link this in the editor or via a variable. # For this example, let's assume we have a Timer variable named 'my_timer'. my_timer: TimerDevice = TimerDevice{} # 2. Configure the Timer. # Set the duration to 60 seconds. my_timer.SetDuration(60.0) # Start the timer immediately when the game starts. my_timer.Start() # 3. Connect the Event. # We are telling the timer: "When you end, call on_timer_finished." # This creates the link between the two devices. my_timer.OnTimerEnd += on_timer_finished