|
| 03 Jan 2014 10:39 PM |
PlayerTable = {} local players = Game:GetPlayers() for i=1,#players do table.insert(PlayerTable, players[i].Name) randplayer = PlayerTable[math.random(1,#PlayerTable)] table.remove(PlayerTable, randplayer.Name) randplayer2 = players[math.random(1,#players)] table.remove(PlayerTable, randplayer2.Name) --code end
Twitter - @askshanerbx, Don't trust koolaidekiller. |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 10:43 PM |
If you're trying to get a random player, you don't have to establish a new table. Just try this:
local players = game.Players:GetPlayers()
local randomPlayer = players[math.random(1, #players)]
print(randomPlayer.Name.." was chosen.") |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 03 Jan 2014 10:47 PM |
^look at wat hes trying to do first...
btw it wont work. here try this.
PlayerTable = Game.Players:GetPlayers() local index1 = math.random(1,#PlayerTable) randPlayer1 = PlayerTable[index1] table.remove(PlayerTable, index1) local index2 = math.random(1,#PlayerTable) randPlayer2 = PlayerTable[index2] table.remove(PlayerTable, index2) |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 03 Jan 2014 10:53 PM |
| @above I did look at what he's trying to do. His answer is no. |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 10:53 PM |
tux, I'm making it so it doesn't choose the same player. and thanks, wazap.
Twitter - @askshanerbx, Don't trust koolaidekiller. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 03 Jan 2014 10:56 PM |
| @trav I was referring to the person above you. You ninjaed while I was typing :c |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 10:57 PM |
wazap so local players = Game:GetPlayers() for i=1,#players do local index1 = math.random(1,#players) randplayer1 = PlayerTable[index1] --do something with randplayer table.remove(PlayerTable, index1) --so he can't be picked again end
Twitter - @askshanerbx, Don't trust koolaidekiller. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 03 Jan 2014 11:00 PM |
Why are you so insistent on Game:GetPlayers() -.-
its Game.Players:GetPlayers()
local players = Game.Players:GetPlayers() for i=1,#players do local index1 = math.random(1,#players) randplayer1 = players[index1] --do something with randplayer table.remove(players, index1) --so he can't be picked again end |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2014 11:01 PM |
I meant game.Players:GetPlayers() lol i keep typo'ing xd
Twitter - @askshanerbx, Don't trust koolaidekiller. |
|
|
| Report Abuse |
|
|