team1 = game.Teams["Survivor"]--By CatAlpha,This is the secert "stuff" script. team2 = game.Teams["Infected"] Game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) Character.Humanoid.Died:connect(function() Player.TeamColor = team2.TeamColor end) end) end)
Just asking but does anybody know how to make 1 random player onto team two?
Well first, you have to know some basic things about tables.
In a table, you can take the table's name followed by brackets and a number, and that gives you the value from the table corresponding to the number, like this:
MyTable = {"Hi","People","I'm","Perci1!"} print(MyTable[1]) print(MyTable[3]) --output: Hi, I'm
Since you can get a value from a table with a number, if we get a random number it should give us a random value. For this we use math.random()
.
MyTable = {"Hi","People","I'm","Perci1!"} randomNumber = math.random(1,#MyTable) --This will pick a random number between 1 and the number of values in the table. randomValue = MyTable[randomNumber] print[randomValue] --Will print a random value.
Now, we will talk about GetPlayers().
GetPlayers()
converts all the player in the server into a table. Therefore we use the same method to get a random player as we used to get a random value.
players = game.Players:GetPlayers() randomNumber = math.random(1,#players) randomValue = players[randomNumber] print(randomValue]
Hope i helped!