sam4life
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 1733 |
|
|
| 05 Aug 2011 05:58 PM |
while true do wait(1) local players = game.Players:GetChildren() for i = 1, #players do Chosen1 = players[math.random(0,players[i])] -- Problem here end OneChosen = Chosen1 if OneChosen ~= nil then if OneChosen.TeamColor == BrickColor.new("Really red") or BrickColor.new("Bright red") then workspace.ChosenOne.Value = OneChosen.Name end wait(0.1) end end
Output: :5:bad argument #2 to 'random' (number expected, got userdata)
Please fix please. The script is supposed to pick a random player from the server if they are on the Red team and set their name as a value. |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2011 05:59 PM |
| Chosen1 = math.random(0, #game.Players:GetChildren()) |
|
|
| Report Abuse |
|
|
sam4life
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 1733 |
|
|
| 05 Aug 2011 06:02 PM |
| Ok but now the value gives me a number when I want a player's name. |
|
|
| Report Abuse |
|
|
sam4life
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 1733 |
|
|
| 05 Aug 2011 06:16 PM |
| Dm, I think I just solved it. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 12:02 PM |
Okay...Use this:
for a, b in pairs(game.Players:GetChildren()) do if a == random_number then OneChosen = b.Name end end |
|
|
| Report Abuse |
|
|
sam4life
|
  |
| Joined: 17 Feb 2009 |
| Total Posts: 1733 |
|
| |
|
| |
|