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: Method for finding how many values are in a table

Previous Thread :: Next Thread 
GamesDoneEasy is not online. GamesDoneEasy
Joined: 10 Jan 2016
Total Posts: 37
03 Sep 2017 12:03 PM
Is there a method to find how many values are in a table, like table.highest or table.amount something like that. I'd rather not use a for loop to count the values if I don't need to.
Report Abuse
Zoumagura is not online. Zoumagura
Joined: 15 Feb 2008
Total Posts: 117
03 Sep 2017 12:04 PM
What's wrong with a for loop? As far as I know it's probably the easiest way.
Report Abuse
Duusskk is not online. Duusskk
Joined: 27 Aug 2013
Total Posts: 651
03 Sep 2017 12:05 PM
Yup, you need to use a for loop if you have non-numerical keys.
Report Abuse
GamesDoneEasy is not online. GamesDoneEasy
Joined: 10 Jan 2016
Total Posts: 37
03 Sep 2017 12:05 PM
A method that I can call on a single line is more efficient than using a for loop.
Report Abuse
chexyalani is online. chexyalani
Joined: 26 Mar 2017
Total Posts: 694
03 Sep 2017 12:05 PM
Use the unary operator, #### to get the number of values in the array. local ex={1,2,3,4,"lol"} ########## --> 5
Report Abuse
GamesDoneEasy is not online. GamesDoneEasy
Joined: 10 Jan 2016
Total Posts: 37
03 Sep 2017 12:08 PM
Ok thanks
Report Abuse
Zoumagura is not online. Zoumagura
Joined: 15 Feb 2008
Total Posts: 117
03 Sep 2017 12:09 PM
If your table is all numbers, save the last value you put into the table and you'll have the highest value in the table.
Report Abuse
Duusskk is not online. Duusskk
Joined: 27 Aug 2013
Total Posts: 651
03 Sep 2017 12:10 PM
Finding number of elements in a table, unary: local items = {"a", "b", "c"} print (#items) -- 3 However that won't work if you have a table like this local data = { cash = ### ###### = 0 } print(#data) -- 0 This is when you need a for loop.
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