|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 25 Nov 2015 06:39 PM |
| Thanks guys, couldn't find that anywhere! |
|
|
| Report Abuse |
|
|