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: Math.Random help.

Previous Thread :: Next Thread 
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
10 Jul 2015 05:54 PM
Okay I need a choosing random player math random thingy mobbob

heres what I've got:

players = game.Players:GetChildren()
local ranPlayer = players[math.random(1, #players)]


okay for my problem it says i am indexing a nil value.

Someone told me this is what is happening

local ranPlayer = players[math.random(1, 0)]

How do I make a script that if there is one player loading in it waits for like 15 seconds but if there is more than 1 player it will skip the wait for 3 seconds. my code still stuffs up with the wait so I am doing something wrong.
Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
10 Jul 2015 05:56 PM
or you could do
repeat wait() until game.Players.NumPlayers > 1
Report Abuse
DesignerDavid is not online. DesignerDavid
Joined: 18 Feb 2014
Total Posts: 8422
10 Jul 2015 05:56 PM
ranPlayer[math.random(1, #players)]

Growing old is mandatory - growing up is optional.
Report Abuse
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
10 Jul 2015 06:02 PM
nope still comes up with trying to index a nil value.
Report Abuse
DesignerDavid is not online. DesignerDavid
Joined: 18 Feb 2014
Total Posts: 8422
10 Jul 2015 06:04 PM
Go on Youtube and search up ROBLOX University. I think I recall when Stickmasterluke did a tutorial of this on the Mad Bloxxer. Not sure.

Growing old is mandatory - growing up is optional.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
10 Jul 2015 06:07 PM
Just wait until there are 2 players in the game.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Jul 2015 06:13 PM
local table = require(199207348)

local ranPlayer = table.random(game.Players:GetPlayers())
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