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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Insert number value into character upon each spawn?

Previous Thread :: Next Thread 
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:29 PM
I'm making an xp system where the value is in the character. How do I insert a value in him, cloning it each death?
Report Abuse
Spectrabox is not online. Spectrabox
Joined: 29 Aug 2008
Total Posts: 6888
22 May 2014 02:31 PM
Starterpack would do that, but you should probably just put it in the player instead of the character.
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:34 PM
Perhaps something like this:

wait()
if ((character).XP == nil) then
local value = Instance.new("NumberValue")
value.Parent = -- Somehow make this the character.
value.name = ("XP")
script.Parent.Humanoid.Died:connect(function()
wait(10)
newvalue = value:clone()
newvalue.Parent = -- Again, somehow make this the character.
newvalue.Name = ("XP")
newvalue.Value = value.Value
end)
end
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:35 PM
Good idea. How do I add a value into each player?
Report Abuse
Spectrabox is not online. Spectrabox
Joined: 29 Aug 2008
Total Posts: 6888
22 May 2014 02:37 PM
I'd say use player added and add it in when they join.
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:40 PM
wait()
local player = --onPlayerEntered?
value = Instance.new("NumberValue")
value.Parent = player.StarterPack
value.Name = ("XP")
end
Report Abuse
Spectrabox is not online. Spectrabox
Joined: 29 Aug 2008
Total Posts: 6888
22 May 2014 02:45 PM
It is a function. Here is the wiki page:

http://wiki.roblox.com/index.php/PlayerAdded_(Event)
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:45 PM
Maybe this?

wait()
local player = game.Players.PlayerAdded
print("Adding the XP value!")
value = Instance.new("NumberValue")
value.Parent = player.StarterGear
value.Name = ("XP")
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:52 PM
Then, why doesn't this work?

wait()
game.Players.PlayerAdded:connect(function(player)
print("Adding the XP value!")
value = Instance.new("NumberValue")
value.Parent = player.StarterGear
value.Name = ("XP")
end)
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
22 May 2014 02:56 PM
Why would you put it in StarterGear? But yeah that should work.
Report Abuse
StrawberryEwok is not online. StrawberryEwok
Joined: 05 Dec 2009
Total Posts: 180
22 May 2014 02:59 PM
I put it in a local script, and it still didn't work. Do I have to put it in players?
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 May 2014 03:01 PM
game.Players.PlayerAdded:connect(function(player) --PlayerAdded event, player argument

--stuff

end
Report Abuse
Perci1 is not online. Perci1
Joined: 24 Jan 2011
Total Posts: 1027
22 May 2014 03:05 PM
Any output? Is anything printing?
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