generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: "bad argument #2 to 'random' (number expected, got table)"

Previous Thread :: Next Thread 
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
13 Sep 2015 04:36 PM
Script isn't working. Output is title.

while wait(1) and game.Players.NumPlayers ~= 0 do
local hum = game.Players:GetPlayers()[math.random(1, game.Players:GetPlayers())].TeamColor
if hum then
hum.TeamColor = BrickColor.new("Bright Red")

hum:LoadCharacter()



end
end
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
13 Sep 2015 04:37 PM
Trying using () instead of []



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$210 Tx2,112
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 04:39 PM
Correct answer:

game.Players:GetPlayers()[math.random(game.Players.NumPlaayers)]


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
13 Sep 2015 04:39 PM
Still didn't work, and had the same output.
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 04:41 PM
*Players


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
13 Sep 2015 04:43 PM
@Two,

I have a hum.LoadCharacter after all of it to see if it works, and all it does is load character over and over. It skips the team color change. No output, just skips it?
Report Abuse
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
13 Sep 2015 04:50 PM
b1
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
13 Sep 2015 05:00 PM
It "skips" the color change because:

BrickColor.new("Bright Red")

Is not a color.

BrickColor.new("Bright red")

Is correct.
Report Abuse
TwoRivers is not online. TwoRivers
Joined: 25 Aug 2011
Total Posts: 2821
13 Sep 2015 05:00 PM
should've read full code smh


-TwoRivers/Iterum/Vulnerite/ChiefDelta/Discommodate/100+ accounts
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
13 Sep 2015 05:02 PM
while wait(1) and game.Players.NumPlayers ~= 0 do
local hum = game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())].TeamColor
if hum then
hum.TeamColor = BrickColor.new("Bright Red")

hum:LoadCharacter()




end
end
Report Abuse
Xeranus is not online. Xeranus
Joined: 15 Mar 2010
Total Posts: 1101
13 Sep 2015 06:43 PM
Sorry, one more thing. It works, but this is meant to pick a random person to be 1 enemy for the round, what would I use to make all other players on another team besides the one picked?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image