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: Is math.random working well?

Previous Thread :: Next Thread 
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
18 Feb 2017 05:23 PM
Everytime I try to choose a random player it fails.

local randomplayer = math.random(1 #game.Players:GetPlayers())
local newplayer = game.Players:GetPlayers[randomplayer]
print(newplayer.Name)
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
18 Feb 2017 05:27 PM
nope, ROBLOX decided to go into ### math library and make math.random() error every time. it's not because you're forgetting a comma after ### first argument/you don't need ### first argument because it's optional
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
18 Feb 2017 05:27 PM
local randomplayer = math.random(1,#game.Players:GetPlayers())
local newplayer = game.Players:GetPlayers()[randomplayer]
print(newplayer.Name)


Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
18 Feb 2017 05:28 PM
why the argument if it's optional?
I guess it might look better to some people but I'm kinda a minimalist when it comes to those things


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
18 Feb 2017 05:29 PM
Even if I forget the brackets in GetPlayers() it still wouldn't have worked
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
18 Feb 2017 05:30 PM
I didn't address that at all because right after seeing your error on the first line I stopped reading the code


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
18 Feb 2017 05:30 PM
I know that too but I tried it once and it didnt work.
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
18 Feb 2017 05:31 PM
and they're called parentheses


Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
18 Feb 2017 05:31 PM
just putting it how he has it. I don't normally use ### first arg if it's not needed. he is also calling for ### table twice instead of just making it a variable but oh well. He wants it like this:(
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
18 Feb 2017 05:32 PM
Ik that too Unsub

I figured it out when another guy on my thread posted the script and added the brackets to GetPlayers() cuz I forgot it.
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
18 Feb 2017 05:33 PM
Why do you guys type so fast?

I cant keep up cuz im on mobile.
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
18 Feb 2017 05:33 PM
## bad
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