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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Retrieve certain table values

Previous Thread :: Next Thread 
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
23 Feb 2015 06:29 PM
Script:

local Table = {1,2,3}
table.sort(Table)
for i,v in ipairs(Table) do
print (i,v)
end

Output:

1 1
2 2
3 3

How would I get it to just display only 1 of those values, like 2?
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:33 PM
local t = {1; 2; 3};
for _, v in pairs(t) do
if v == 2 then
print(_, v);
end;
end;
Report Abuse
bomblover is not online. bomblover
Joined: 23 Mar 2011
Total Posts: 238
23 Feb 2015 06:35 PM
local Tab = {1,2,3,4,5,6,7,8,9}

for i,v in pairs(Tab) do
if v == 2 then
print("A two was found in the local table 'Tab'")
end
end
Report Abuse
Stefan631 is not online. Stefan631
Joined: 23 Dec 2010
Total Posts: 1350
23 Feb 2015 06:36 PM
NINJAAA
Report Abuse
bomblover is not online. bomblover
Joined: 23 Mar 2011
Total Posts: 238
23 Feb 2015 06:36 PM
@Stefan when outputting the index don't use a placeholder to represent it.
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
23 Feb 2015 06:55 PM
local Table = {Apple.Value, Banana.Value}
table.sort(Table)
for i,v in pairs(Table) do
if v >= 1 then
print (i,v);
end end


So if any of the values are larger or equal to 1 it returns the key [1] or [2] and the value. How would I make it return the key's name: [1] = "Apple" with the given value change.
Report Abuse
bomblover is not online. bomblover
Joined: 23 Mar 2011
Total Posts: 238
23 Feb 2015 07:03 PM
Would you explain what you're trying to do/make? It's much easier to help you that way.
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
23 Feb 2015 07:41 PM
Organize the values, and also provide the name of the Values
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
23 Feb 2015 07:57 PM
bump
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
23 Feb 2015 08:08 PM
b2
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