# This is our Team Door script # It runs when a player steps on the trigger using { /Fortnite.com/Devices } using { /Fortnite.com/Game } using { /Fortnite.com/Teams } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We attach this class to a trigger_device placed in the editor team_door_device := class(creative_device): # Reference to the trigger device placed in the editor @editable Trigger : trigger_device = trigger_device{} # Reference to an item_granter_device placed in the editor. # Set its item to Shield Potion Small in the UEFN editor properties. # note: Verse has no direct GrantItem() API; item_granter_device is the real mechanism. @editable ItemGranter : item_granter_device = item_granter_device{} # OnBegin runs once when the island starts OnBegin() : void = # Subscribe to the trigger's TriggeredEvent Trigger.TriggeredEvent.Subscribe(OnTriggerEnter) # This function runs when a player steps on the trigger OnTriggerEnter(Agent : ?agent) : void = # Check if the agent is actually a player if (ActualAgent := Agent?): if (Player := player[ActualAgent]): # Ask the game for this player's team collection # GetTeamCollection() is a method on fort_playspace Playspace := GetPlayspace() TeamCollection := Playspace.GetTeamCollection() # GetTeam() returns an option; the 'if' unwraps it if (Team := TeamCollection.GetTeam[Player]): # GetTeams() returns all teams; find the index by locating our team in the array # note: fort_team_collection has no GetTeamIndex(); we compare teams manually. Teams := TeamCollection.GetTeams() var TeamIndex : int = 0 var Idx : int = 0 for (T : Teams): set Idx = Idx + 1 if (T = Team): set TeamIndex = Idx # Let's check if they are on Team 1 (index 1) if (TeamIndex = 1): # They are on Team 1! Give them a gift via the item granter. ItemGranter.GrantItem(ActualAgent) # Print a message to the chat for fun # note: Print() writes to the UEFN output log; no in-game chat API exists in Verse. Print("You are on Team 1! Here is a potion!") else: # They are NOT on Team 1. # Do nothing, or say hello. Print("You are not on Team 1. Try again!")