hello I tried to make a script for the last standing team to win except for team 1, so 2-5 can win. but i have this error, what am i doing wrong?
module LastTeamStanding
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
LastTeamStanding := class(creative_device):
# Teams 2-5 are eligible to win
EligibleTeamIndices : []int = array{ 2, 3, 4, 5 }
# Runs when the device is started in a running game
OnBegin<override>()<suspends>: void = {
Elimination.OnPlayerEliminated.Subscribe(OnPlayerEliminated)
}
# Function triggered when a player is eliminated
OnPlayerEliminated := (player : Agent, eliminator : Agent) : void => {
if (Agent.IsPlayer(player)):
CheckForWinner()
}
}
# Checks if only one eligible team remains
CheckForWinner := () : void => {
var remainingTeams : []team = array{}
# Check each eligible team
for (teamIndex : int in EligibleTeamIndices):
var currentTeam : team = Team.GetByIndex(teamIndex)
var playersRemaining : []agent = currentTeam.GetAgents().Filter(Agent.IsPlayer)
if (playersRemaining.Length > 0):
remainingTeams = remainingTeams.Push(currentTeam)
# If only one eligible team remains, they win
if (remainingTeams.Length == 1):
Game.EndRoundForTeam(remainingTeams[0])
}
}