ok so basically this is an event, and when it fires, i want a random person from the other team to freeze, but it doesn't work because it's nil value. is there a way i can fix it to ensure it chooses a player from the other team?
if plr.Team == game.Teams.Blue then repeat local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] wait() until randomPlayer.Team == game.Teams.Red local freeze = game.Lighting.Freeze:Clone() freeze.Parent = randomPlayer.Character randomPlayer.Character.HumanoidRootPart.Anchored = true wait(8) randomPlayer.Character.HumanoidRootPart.Anchored = false freeze:Remove() elseif plr.Team == game.Teams.Red then local randomPlayer = game.Players:GetPlayers() repeat local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] wait() until randomPlayer.Team == game.Teams.Blue local freeze = game.Lighting.Freeze:Clone() freeze.Parent = randomPlayer.Character randomPlayer.Character.HumanoidRootPart.Anchored = true wait(8) randomPlayer.Character.HumanoidRootPart.Anchored = false freeze:Remove()
Well first of all you can just do
local Team = game.Teams.Blue:GetPlayers() local Chosen = Team[math.random(1, #Team) Chosen.Team = game.Teams.Red