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: Why doesnt this work

Previous Thread :: Next Thread 
LevelPown is not online. LevelPown
Joined: 03 Jun 2009
Total Posts: 35
29 Jul 2012 12:03 PM
Why doesnt it print anything. It says nil in output


wait(2)
local p = game.Players:GetChildren()
local you = game.Players:findFirstChild(math.random(1,#p))
local players = {}
players[1]=you
print(players[1])



Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
29 Jul 2012 12:04 PM
local allPlayers = game.Players:GetChildren();
local randPlayer = allPlayers[math.random(1, #allPlayers)];

print(randPlayer.Name);
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
29 Jul 2012 12:05 PM
>Why doesnt it print anything.
>It says nil in output

?
Report Abuse
LevelPown is not online. LevelPown
Joined: 03 Jun 2009
Total Posts: 35
29 Jul 2012 12:05 PM
ya but I want the player to be added to a table
Report Abuse
robotmega is not online. robotmega
Joined: 16 May 2009
Total Posts: 14084
29 Jul 2012 12:07 PM
local players = {}

wait(2)
local p = game.Players:GetChildren()
local you = game.Players:findFirstChild(math.random(1,#p))
players[1]=you
print(players[1])
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
29 Jul 2012 12:08 PM
local players = {randPlayer};
Report Abuse
LevelPown is not online. LevelPown
Joined: 03 Jun 2009
Total Posts: 35
29 Jul 2012 12:14 PM
And how do I remove the player from the table after a length of time?
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
29 Jul 2012 12:15 PM
http://wiki.roblox.com/index.php/Function_Dump/Table_Manipulation#table.remove
Report Abuse
Thewsomeguy is not online. Thewsomeguy
Joined: 06 Aug 2011
Total Posts: 520
29 Jul 2012 12:16 PM
wait() -- Change this,Since it is just one frame
table.remove(Players,Players[1]) --Maybe it works.
Report Abuse
LevelPown is not online. LevelPown
Joined: 03 Jun 2009
Total Posts: 35
29 Jul 2012 12:23 PM
does
local players = {randPlayer};
select a random player?
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
29 Jul 2012 12:24 PM
No, this does:
local allPlayers = game.Players:GetChildren();
local randPlayer = allPlayers[math.random(1, #allPlayers)];
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