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 » Scripting Helpers
Home Search
 

Re: Can I store a player in a variable?

Previous Thread :: Next Thread 
NeonBlox is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. TwoBoo
Joined: 08 Feb 2011
Total Posts: 10790
22 Jan 2012 05:37 PM
What does table.maxn do?
Report Abuse
moustachauve is not online. moustachauve
Joined: 29 Jul 2009
Total Posts: 668
22 Jan 2012 05:37 PM
@MrNicNac Can you explain me this script please?
Report Abuse
Penguine236 is not online. Penguine236
Joined: 13 Apr 2011
Total Posts: 1303
22 Jan 2012 06:34 PM
@Neon

WARNING:

That would only move the very last player that the loop counted.
Report Abuse
oxcool1 is not online. oxcool1
Joined: 05 Nov 2009
Total Posts: 15444
22 Jan 2012 07:15 PM
[ Content Deleted ]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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