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: Reading from a table

Previous Thread :: Next Thread 
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
26 Jun 2012 02:58 PM
I'm sure that this is a simple question.
Lets say I have a table:
myTable = game.Players:GetChildren()
and I wanted to edit a player in that table's torso.
Would this be right?
myTable[1].Character.Torso:Remove()
Report Abuse
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
26 Jun 2012 03:01 PM
Well, that would change a player's torso, assuming that one player was in the server. What would be better would be to randomize it:

if #myTable > 0 then
myTable[math.random(1,#myTable)].Character.Torso:remove()
end

-God Bless-
Report Abuse
ComBatPro is not online. ComBatPro
Joined: 27 Dec 2010
Total Posts: 205
26 Jun 2012 03:06 PM
That's a great way to do.
Report Abuse
PurelyRandom is not online. PurelyRandom
Joined: 05 Mar 2011
Total Posts: 36763
26 Jun 2012 03:44 PM
@noober;

What does this line do?

myTable[math.random(1,#myTable)].Character.Torso:remove()


I just want to know for future references.
Report Abuse
Jellyfish403 is not online. Jellyfish403
Joined: 12 May 2010
Total Posts: 951
26 Jun 2012 04:15 PM
So you put a period in front of the brackets?
Report Abuse
noobertuber is not online. noobertuber
Joined: 16 Jan 2007
Total Posts: 2321
26 Jun 2012 04:58 PM
It chooses a random child of myTable.

Yes, the period is to denote a child of the object value stored in myTable.

-God Bless-
Report Abuse
fireblade2 is not online. fireblade2
Joined: 18 Nov 2007
Total Posts: 4666
26 Jun 2012 05:07 PM
And if you want to be really fancy about it, you could even do the following:

myTable[math.random(#myTable)].Character.Torso:remove() --Notice the removal of "1," in math.random()
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