ruebot
|
  |
| Joined: 08 Feb 2008 |
| Total Posts: 203 |
|
|
| 22 Jul 2011 08:51 AM |
This is a part of my script (That has an error)
local m = math.random(join, 3) -- I though that this would choose 3 players out of all players.
m.join.TeamColor = "Dark green"
-- How do I make it choose 3? |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2011 08:54 AM |
local plyrs = game.Players:GetChildren() for i = 1, 3 do local X = math.random(1, #plyrs) plyrs[X].TeamColor = BrickColor.new("Dark green") table.remove(plyrs, X) end
~~~ AFF ~~~ |
|
|
| Report Abuse |
|
|
Alex645ca
|
  |
| Joined: 02 Feb 2009 |
| Total Posts: 2531 |
|
|
| 22 Jul 2011 09:00 AM |
@Agent
I was just reading the object browser because I found a bunch of random new object classes in the insert>object menu, and the getchildren tables are read-only.
local plyrs = game.Players:GetChildren() for i = 1, 3 do local X = math.random(1, #plyrs) if plyrs[X].TeamColor ~= BrickColor.new("Dark green") then plyrs[X].TeamColor = BrickColor.new("Dark green") else i = i - 1 end end
I suppose that would work better, idk.
|
|
|
| Report Abuse |
|
|
|
| 22 Jul 2011 09:09 AM |
| Nothing out of the league here, but won't both of your scripts allow the script to chose the player over? Like it choses the same player? |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2011 01:55 PM |
"and the getchildren tables are read-only."
That statement is a lie.
t = workspace:GetChildren() print(#t) table.remove(t, 1) print(#t) > 7 > 6
~~~ AFF ~~~ |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2011 02:15 PM |
local player game.Players:GetPlayers() print(player[math.random(3,#player)])
Much easier |
|
|
| Report Abuse |
|
|