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: How do you get the position of a string in a table?

Previous Thread :: Next Thread 
Born2Script is not online. Born2Script
Joined: 23 Jul 2013
Total Posts: 2670
20 Jun 2015 05:56 PM
Well.. I'm looking for how do you get the position of an object in a table but I guess it's the same

for example, I want to find what number "String" is in a table. How? Thank you
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jun 2015 05:58 PM
for key = 1, #tbl do
if tbl[key] == "String" then
print(key);
break;
end
end
Report Abuse
QuintinityZero is not online. QuintinityZero
Joined: 01 Oct 2008
Total Posts: 10618
20 Jun 2015 05:58 PM
Assuming no duplicates and the indexes are numerical

function getIndex(tab, value)
for i, v in pairs(tab) do
if value == v then
return i;
end
end
return -1;
end
Report Abuse
QuintinityZero is not online. QuintinityZero
Joined: 01 Oct 2008
Total Posts: 10618
20 Jun 2015 05:59 PM
Erm, #tab is better than ipairs(tab), just rememberd
Report Abuse
Born2Script is not online. Born2Script
Joined: 23 Jul 2013
Total Posts: 2670
20 Jun 2015 06:05 PM
Alright thanks..
?
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
20 Jun 2015 06:06 PM
you were born to script

i can't tell if that's really amusing or sarcastic or just random or extremely pretentious
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jun 2015 06:07 PM
Wow very on-topic comment /sarcasm
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
20 Jun 2015 06:08 PM
i am not socially inept u dont need a /sarcasm tag so i can understand

Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
20 Jun 2015 06:08 PM
I think he needed to add some attributes though
Report Abuse
Born2Script is not online. Born2Script
Joined: 23 Jul 2013
Total Posts: 2670
20 Jun 2015 06:09 PM
My name isn't "IKnowAllAboutScript".. it is "Born2Script". And people learn thing everyday. Deal with it. I have more threads incoming
Report Abuse
acidflip is not online. acidflip
Joined: 18 Jul 2012
Total Posts: 886
20 Jun 2015 06:36 PM
"My name isn't "IKnowAllAboutScript".. it is "Born2Script". And people learn thing everyday. Deal with it. I have more threads incoming"

read the god damn wiki before posting all of your questions here
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