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()

3 comments
is this supposed to switch a player from blue to red team?
Yes it changes a random players team from blue to red. If it works make sure to mark it as the answer!
i meant that i wanted to choose a person from a different team but the 2 first line works!