Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I am trying to make a script who is put player into team randomly but that not working ?

local Teams = game:GetService("Teams")
local T_Name = {"Blue Fighter","Red Fighter"}
for _,player in pairs(game.Players:GetPlayers()) do
	if player and Teams then
		player.Team = Teams[math.random(, #T_Name)]
	end
	end

1 answer

✓ Accepted answer

Try

local Teams = game:GetService("Teams")
local T_Name = {
    [1] = "Blue Fighter",
    [2] = "Red Fighter"
}

for _,player in pairs(game.Players:GetPlayers()) do
    player.Team = Teams:FindFirstChild(T_Name[math.random(1, #T_Name)])
end

This discussion is preserved as it was. New answers, comments, and votes are closed.