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 » Scripting Helpers
Home Search
 

Re: Script Problem(got output)

Previous Thread :: Next Thread 
sam4life is not online. 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
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
05 Aug 2011 05:59 PM
Chosen1 = math.random(0, #game.Players:GetChildren())
Report Abuse
sam4life is not online. 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 is not online. sam4life
Joined: 17 Feb 2009
Total Posts: 1733
05 Aug 2011 06:16 PM
Dm, I think I just solved it.
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
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 is not online. sam4life
Joined: 17 Feb 2009
Total Posts: 1733
06 Aug 2011 12:28 PM
Ok I'll try that too.
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
06 Aug 2011 03:27 PM
Kk.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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