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: question

Previous Thread :: Next Thread 
Veloric is not online. Veloric
Joined: 24 Jul 2013
Total Posts: 12668
08 Aug 2016 08:36 PM



what does the i do in a for i,v in pairs() loop


like i never knew this


/Vel/
Report Abuse
Wowgnomes is not online. Wowgnomes
Joined: 27 Sep 2009
Total Posts: 26255
08 Aug 2016 08:37 PM
identifier

part[i].transparency = 0 etc
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
08 Aug 2016 08:40 PM
It iterates over a table/dictionary/list/array. (Different names, same thing in Lua)

i is the Index or Key, the position in the table where it is located.
For a list/array, it is an integer ranging from 1 to more than you can count to in three hours.
For a dictionary, it is the key which can be a string, number, Instance, pretty much anything.

v is the Value, the element in the table.


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
08 Aug 2016 09:06 PM
I think it helps to see an example.

local tab = {"a", "b", "c", "d"}

for i,v in pairs(tab) do
print('index is '..i..', value is '..v)
end

>index is 1, value is a
>index is 2, value is b
>index is 3, value is c
>index is 4, value is d

Basically it runs the code in the loop for each value in the table, and for that value i is set to the index and v is set to the value.
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