LevelPown
|
  |
| Joined: 03 Jun 2009 |
| Total Posts: 35 |
|
|
| 29 Jul 2012 12:03 PM |
Why doesnt it print anything. It says nil in output
wait(2) local p = game.Players:GetChildren() local you = game.Players:findFirstChild(math.random(1,#p)) local players = {} players[1]=you print(players[1])
|
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 29 Jul 2012 12:04 PM |
local allPlayers = game.Players:GetChildren(); local randPlayer = allPlayers[math.random(1, #allPlayers)];
print(randPlayer.Name); |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2012 12:05 PM |
>Why doesnt it print anything. >It says nil in output
? |
|
|
| Report Abuse |
|
|
LevelPown
|
  |
| Joined: 03 Jun 2009 |
| Total Posts: 35 |
|
|
| 29 Jul 2012 12:05 PM |
| ya but I want the player to be added to a table |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 29 Jul 2012 12:07 PM |
local players = {}
wait(2) local p = game.Players:GetChildren() local you = game.Players:findFirstChild(math.random(1,#p)) players[1]=you print(players[1]) |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 29 Jul 2012 12:08 PM |
| local players = {randPlayer}; |
|
|
| Report Abuse |
|
|
LevelPown
|
  |
| Joined: 03 Jun 2009 |
| Total Posts: 35 |
|
|
| 29 Jul 2012 12:14 PM |
| And how do I remove the player from the table after a length of time? |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 29 Jul 2012 12:15 PM |
| http://wiki.roblox.com/index.php/Function_Dump/Table_Manipulation#table.remove |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2012 12:16 PM |
wait() -- Change this,Since it is just one frame table.remove(Players,Players[1]) --Maybe it works. |
|
|
| Report Abuse |
|
|
LevelPown
|
  |
| Joined: 03 Jun 2009 |
| Total Posts: 35 |
|
|
| 29 Jul 2012 12:23 PM |
does local players = {randPlayer}; select a random player? |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 29 Jul 2012 12:24 PM |
No, this does: local allPlayers = game.Players:GetChildren(); local randPlayer = allPlayers[math.random(1, #allPlayers)]; |
|
|
| Report Abuse |
|
|