Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
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

Log in to vote
0
Answered by 5 years ago

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
Ad

Answer this question