peaspod
|
  |
| Joined: 29 Sep 2010 |
| Total Posts: 2809 |
|
|
| 25 Dec 2012 02:07 PM |
What I don't get is that for i = 1, 10 do ..... is basically the same as for i, v in pairs (game.Players:GetPlayers()) do.
Example I wanna remove the tools in everyone's backpack
ex 1:
p = (game.Players:GetPlayers() for i = 1, #p do p[i].BackPackClearAllChildren() end
ex 2:
for i, v in pairs (game.Players:GetPlayers()) do v.BackPack:ClearAllChildren() end
Basically the same but 1 less line of code. What specific thngs would you use pairs for which you wouldn't use the other "for loop" for? |
|
|
| Report Abuse |
|
|
Aqualogy
|
  |
| Joined: 01 Dec 2012 |
| Total Posts: 226 |
|
|
| 25 Dec 2012 02:08 PM |
| Scripting Helpers will help you. |
|
|
| Report Abuse |
|
|
|
| 25 Dec 2012 02:19 PM |
This will do it, but like many drugs, has side effects:
Instance.new("ManualSurfaceJointInstance") |
|
|
| Report Abuse |
|
|
|
| 25 Dec 2012 02:56 PM |
>Trolling >Respectable creator of games >CHRISTMAS
Shame.
SHAME. |
|
|
| Report Abuse |
|
|
|
| 25 Dec 2012 03:00 PM |
">Respectable creator of games"
lol no |
|
|
| Report Abuse |
|
|
| |
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|
|
| 25 Dec 2012 05:10 PM |
Pairs can be used for non-numeric (and non-consecutive) indexes.
-God Bless- |
|
|
| Report Abuse |
|
|
Luc599345
|
  |
| Joined: 25 Jul 2008 |
| Total Posts: 1169 |
|
|
| 25 Dec 2012 09:16 PM |
| None of the scripts you've wrote actually works. :/ |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 25 Dec 2012 09:48 PM |
For i = num1, num2 can do lots of things, it's basically to loop somthing for any amount of time, however if you did a for i, v in pairs(dndgnkfd) do
It would just repeat for amount of things within. Like
x = game.Players:GetChildren()
for i = 1,#x do
if x[i].ClassName == "Part" then
x[i]:Remove()
end
end
That would remove all the things within the player that has the classname part, how it does this is looping through it all and deleting 1 each loop, while
for i = 1,100 do wait() print("This Has Been Printed, "..i.." times!") end
Would repeat the loop 100 times, then stop.
Woul |
|
|
| Report Abuse |
|
|
cybris
|
  |
| Joined: 01 Mar 2008 |
| Total Posts: 2424 |
|
|
| 25 Dec 2012 10:38 PM |
| I think crouton was the only one who got what he was trying to say lol, he isn't spamming the forum, he has a question about scripting, so he is discussing it. He is not asking for help with a specific bit of a script, he just gave a general example to help us visualize the topic of discussion. He is asking what you would use "pairs" for that you would not use "for" for |
|
|
| Report Abuse |
|
|
cybris
|
  |
| Joined: 01 Mar 2008 |
| Total Posts: 2424 |
|
|
| 25 Dec 2012 10:39 PM |
| Oh and nubertuber answered too :) |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|