# We need to access the core Fortnite systems use FortniteGameVerse:// # This is our main "Game Class". Think of it as the brain of your island. # It holds all the variables and functions for your game mode. team_elimination_game = class(Game): # This is a "Function". It’s a block of code that does a specific job. # We will call this function whenever a Sentry is eliminated. # The `?agent` part means "The person who killed the Sentry, IF there was one." # It's optional because sometimes traps kill sentries, and traps aren't players. TestPlayerEliminated(Agent : ?agent) : void = # This checks if 'Agent' actually has a value (is not empty). # If a player killed the sentry, Agent will have data. # If a trap killed it, Agent will be empty (None). if Agent != None: # Print is like the in-game chat log, but only for developers. # It helps us debug without cluttering the player screen. Print("Sentry Down! Player eliminated it.") else: Print("Sentry Down! Trap or glitch eliminated it.") # This function runs once when the game starts. Initialize() : void = # Get the specific Sentry device we placed in the editor. # You must name your Sentry device in the editor to match this string. sentry := GetEntity("TestSentry") # HERE IS THE MAGIC: # We subscribe to the Sentry's EliminatedEvent. # Whenever the sentry dies, Verse automatically calls TestPlayerEliminated. # We pass our function name as the "listener". sentry.EliminatedEvent.Subscribe(TestPlayerEliminated)