NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 22 Jan 2012 05:21 PM |
for index,player in pairs(game.Players:GetPlayers()) do player..index = player end
Can I store a player in a variable? Would the first player to go through be stored in player1? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 22 Jan 2012 05:24 PM |
| 'player' is already the variable name of the player. |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 22 Jan 2012 05:27 PM |
Okay, but would this move the last player to run through the for loop to 0,0,0?
for i,v in pairs(game.Players:GetPlayers()) do theplayer = v end theplayer.Character:MoveTo(Vector3.new(0,0,0)) |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 22 Jan 2012 05:30 PM |
Yes. But there is a better way than a loop.
local lastPlayer = Game.Players:GetPlayers()[table.maxn(Game.Players:GetPlayers())] lastPlayer.Character:MoveTo(Vector3.new(0,0,0)) |
|
|
| Report Abuse |
|
|
NeonBlox
|
  |
| Joined: 19 Oct 2008 |
| Total Posts: 1462 |
|
|
| 22 Jan 2012 05:32 PM |
| I know there was a better way, I just used it as a example to see if I could store a player in a variable. Thanks MrNicNac. |
|
|
| Report Abuse |
|
|
TwoBoo
|
  |
| Joined: 08 Feb 2011 |
| Total Posts: 10790 |
|
| |
|
|
| 22 Jan 2012 05:37 PM |
| @MrNicNac Can you explain me this script please? |
|
|
| Report Abuse |
|
|
|
| 22 Jan 2012 06:34 PM |
@Neon
WARNING:
That would only move the very last player that the loop counted. |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
| |
|