How can I put a random player on a team and all the rest on the other?
hi @nelmi
There is a similar problem with an answer
I read it and it doesn’t answer my issue, I’m trying to pick a player from the array and set him to team 1 (simple enough) but I don’t know how to get the other players to team two
Not sure if you managed since you last posted, but you just need to randomly pick a player index and iterate through the list of players and compare each player index. You then just decide which team to move them to.
Here’s an untested snippet.
using { /Fortnite.com/Devices }
using { /Verse.org/Random }
team_splitter_device := class(creative_device):
SplitPlayers():void=
# Retrieve all current players
Players := GetPlayspace().GetPlayers()
# Randomly select one player
RandomIndex := GetRandomInt(0, Players.Length - 1)
if:
# Retrieve the teams
FortTeamCollection := GetPlayspace().GetTeamCollection()
Teams := FortTeamCollection.GetTeams()
TeamSolo := Teams[0] # Team 1 will be the solo player
TeamOthers := Teams[1] # Team 2 will be the others
then:
for(PlayerIndex -> Player:Players):
# Move the randomly selected player to their solo team
if(PlayerIndex = RandomIndex, FortTeamCollection.AddToTeam[Player, TeamSolo]):
# Move the other players to the other team
else if(FortTeamCollection.AddToTeam[Player, TeamOthers]):
Hope that answers your question!
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.