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

It isn´t working? [Team Chooser] D:

Asked by 10 years ago

Hello there, I am having trouble with the game choosing certain players, I want the script to choose only 1 player and put it on the red team however this isnĀ“t working is there any error with this?

Wait(30)
function doTeam()
local playerDir = game.Players:GetPlayers(); -- local var to prevent out-of-scope reference
local chosen = playerDir[math.random(1, #playerDir)]; 
red = {}; 
table.insert(red, chosen.Name); 
for index,value in next, game.Players:GetPlayers() do
if not (value.Name == red[1]) then
value.TeamColor = game.Teams["Blue team"].TeamColor;
else value.TeamColor = game.Teams["Red team"].TeamColor;
end
end
end

doTeam()

BTW it is in a normal script that might also be an error I will check it.

Answer this question