I am trying to make a script for a round based game where two people get picked to become Presidential nominees and debate, this is the script that chooses the to players and puts them on the two different teams (Democrat and Republican) but it stops working midway through the '_G.Teams' function.
local Teams = game:GetService("Teams") local blueParty = Teams["Democratic Party"] local redParty = Teams["Republican Party"] local playersOnRedTeam = game:GetService("Teams")["Republican Party"]:GetPlayers() local playersOnBlueTeam = game:GetService("Teams")["Democratic Party"]:GetPlayers() local function selectPlayer() local players = game.Players:GetPlayers() local selected = players[math.random(1,#players)] return selected end _G.Teams = function() local randomPlayer = selectPlayer() local selectedTeam = math.random(1,2) if randomPlayer and randomPlayer.Character then if randomPlayer.Team == redParty then print("We can't pick this player!") wait() selectPlayer() wait() _G.Teams() elseif randomPlayer.Team == blueParty then print("We can't pick this player!") wait() selectPlayer() wait() _G.Teams() else if selectedTeam == 1 then if #playersOnRedTeam >= 1 then randomPlayer.Team = blueParty else randomPlayer.Team = redParty end end end end end