Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 04:11 PM |
| What exactly does that mean? I've seen it in a few scripts, but i've never had to use it in a script that I've made. Could someone explain it to me? |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2013 04:12 PM |
It loops through a designated table.
v would be the value |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 04:13 PM |
| Okay, how/when would I need to use it in a script? |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2013 04:14 PM |
| http://wiki.roblox.com/index.php/Function_Dump/Core_Functions#pairs |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 04:16 PM |
| Alright, thanks. One more thing, could it be used for pairing up players in a game? Like for a 2v2 game? |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2013 04:17 PM |
Oh yeah.
"U BROKE THE TV U IDIOT!" - CeaselessSoul |
|
|
| Report Abuse |
|
|
9HB
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2461 |
|
|
| 07 Oct 2013 04:17 PM |
Yes you could, that's an example of why you'd use it.
You'd loop through the 4 players you picked and assign them red or blue etc. |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 04:19 PM |
| Okay, thanks for all the help guys. |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 04:31 PM |
Actually, two more things, for the pairing up of the players, could I have more than two pairs? like "for i,v,x in pairs"? The second thing, how would I pair up the players with it? Like this?: for i,v in pairs(game.Players:GetPlayers()) do v.Teamcolor = Brickcolor.new("Bright red") i.Teamcolor = Brickcolor.new("Bright yellow") end |
|
|
| Report Abuse |
|
|
|
| 07 Oct 2013 04:32 PM |
v = the child(value) i = a number v.TeamColor = BrickColor.new("Bright red") also, you only have 2, name it anything it doesnt ahve to be i,v |
|
|
| Report Abuse |
|
|
9HB
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2461 |
|
|
| 07 Oct 2013 04:55 PM |
Your code:
for i,v in pairs(game.Players:GetPlayers()) do v.Teamcolor = Brickcolor.new("Bright red") i.Teamcolor = Brickcolor.new("Bright yellow") end
My code:
plrs = game.Players:GetChildren()
x = Brickcolor.new("Bright red") y = Brickcolor.new("Bright yellow")
for i,v in pairs(plrs) do if i = 1 or i = 3 v.Teamcolor = x if i = 2 or i = 4 v.Teamcolor = y else end |
|
|
| Report Abuse |
|
|
Adam2090
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 889 |
|
|
| 07 Oct 2013 05:07 PM |
| Okay, I see how it works now. |
|
|
| Report Abuse |
|
|
9HB
|
  |
| Joined: 11 Dec 2012 |
| Total Posts: 2461 |
|
|
| 08 Oct 2013 02:06 AM |
| Don't even know if my code works, will only work for 4 ppl. |
|
|
| Report Abuse |
|
|