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: Scripting Help for _,v in pairs() do

Previous Thread :: Next Thread 
RobloxBlux is not online. RobloxBlux
Joined: 18 Jun 2015
Total Posts: 41
25 Nov 2015 06:32 PM
Ok so I understand the regular for i,v in pairs() do
And I have been told by many tutorials that you could change i and v to whatever you wanted, however I see an underscore being used for i a lot in scripts and I know it isn't the same could someone explain what the underscore does or what it is. Sorry if you think this is a dumb question, but I'm new to scripting
Report Abuse
Ristone3 is not online. Ristone3
Joined: 17 Aug 2008
Total Posts: 693
25 Nov 2015 06:35 PM
No question is a dumb question.

The underscore is basically just ignored. If I don't want to know the key of the object, then I put the underscore so it's basically ignored.

In i,v

The i is the index
The v is the value.

In _,v
The _ is ignored
The v is the value
Report Abuse
CDHeli is not online. CDHeli
Joined: 25 Oct 2010
Total Posts: 1264
25 Nov 2015 06:38 PM
Yeah, Ristone is right.

Say you wanted to filter through an object, you use the underscore because you're not looking for the index, you're looking for a value.

for _,v in pairs(game.Workspace.Model:GetChildren()) do
v.PartExample --So in this case, the value is the model and I do . to find a child
end)

Obviously, you'd add more after PartExample... but that's just an example. Good luck!
Report Abuse
RobloxBlux is not online. RobloxBlux
Joined: 18 Jun 2015
Total Posts: 41
25 Nov 2015 06:39 PM
Thanks guys, couldn't find that anywhere!
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