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 anyone tell me...

Previous Thread :: Next Thread 
Hazor is not online. Hazor
Joined: 09 Feb 2009
Total Posts: 5804
03 Sep 2011 11:02 PM
How exactly do you add a variable into a player when they enter the game? Just a question... I am going to need to do it for a project I am working on.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:04 PM
game.Players.PlayerAdded:connect(function(Player)
--Statements
end)

Player would be the variable for the new player or you could always just use a local script.
Report Abuse
Hazor is not online. Hazor
Joined: 09 Feb 2009
Total Posts: 5804
03 Sep 2011 11:06 PM
Well... uh, the Variable part was what I was looking for...
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:07 PM
Then change Player to Part. . .
Report Abuse
Hazor is not online. Hazor
Joined: 09 Feb 2009
Total Posts: 5804
03 Sep 2011 11:10 PM
No, I mean, how do you add the variable? Is it:

"Insert.variable" or did I get that wrong??
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
03 Sep 2011 11:10 PM
A variable is a number value.

You mean Insert.table, or leaderstats?

­<'+1 Post. Ujelly?'> IT'S A PEAR http://www.roblox.com/Pear-Hat-item?id=60907280
Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:11 PM
What do you mean by variable? Can you explain?

What I think:
SavedPlayers = {}

game.Players.PlayerAdded:connect(function(Player)
table.insert(SavedPlayers,Player)
end)
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:11 PM
game.Players.PlayerAdded:connect(function(Player)


Thats the connection line

the argument inside the parentheses after function is the variable? I don't get it if you mean something else
Report Abuse
Hazor is not online. Hazor
Joined: 09 Feb 2009
Total Posts: 5804
03 Sep 2011 11:15 PM
Ok, by variable, I mean a number variable that I can use in different scripts.

For example, a lava brick may or may not kill a person steping on it, depending on the current value of the Variable. What I don't know is, how do I make a script that adds said variable into the character or humanoid inthe first place...
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:17 PM
Oh you mean _G?

Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:18 PM
Oh, is that so. Use _G or something similar, Global.

game.Players.PlayerAdded:connect(function(Player)
_G[Player.Name] = Player
end)
Report Abuse
Hazor is not online. Hazor
Joined: 09 Feb 2009
Total Posts: 5804
03 Sep 2011 11:19 PM
Umm.... _G?
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:20 PM
Just checked the wiki on it.

They changed it to shared? I never used it so I never payed attention.
Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:21 PM
Yes, Global. Which what all script can access.

table.insert <--Function from _G
math.random <--Function from _G
Insert <--Table from _G
string <--Table from _G
Report Abuse
izzatnasruna is not online. izzatnasruna
Joined: 09 Jun 2009
Total Posts: 1927
03 Sep 2011 11:21 PM
There are two, _G and shared. Both are the same.
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
03 Sep 2011 11:22 PM
You use _G to index global variables.

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