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 » Scripters
Home Search
 

Re: Keeping a player's NumberValue after death

Previous Thread :: Next Thread 
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 03:16 PM
How do I do that? Each time a player dies, the NumberValue resets to 0, even if it was over 0 before death.
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
12 Jul 2017 03:19 PM
where are you storing it?
Report Abuse
LeafDoode is not online. LeafDoode
Joined: 29 May 2017
Total Posts: 3094
12 Jul 2017 03:21 PM
maybe having a backup variable?

local Player = game.Players.LocalPlayer
local Character = Player.Character


game.Players.PlayerAdded:connect(function(Player)
Value = Instance.new("IntValue",Player)
Value.Name = "MyValue"
BackupVariable = Value.Value
end)

Value.Changed:connect(function()
BackupVariable = Value.Value
end)

Character.Humanoid.Died:connect(function()
Player:FindFirstChild("MyValue").Value = BackupVariable
end)
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 03:21 PM
I inserted it directly into the Player upon joining :)
so game.Players.[name].Amount
Report Abuse
LeafDoode is not online. LeafDoode
Joined: 29 May 2017
Total Posts: 3094
12 Jul 2017 03:23 PM
that's all i can think of.
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 03:24 PM
That's clever! I'll think I'll stick to that unless someone gives me something easier :) Thanks man
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
12 Jul 2017 03:27 PM
you're doing something wrong---

script in serverscriptservice:

game.Players.PlayerAdded:connect(function(plr)
local val = Instance.new("BoolValue", plr)
val.Value = true
end)

value doesn't reset to false on death, things in player don't default every death unless in playergui/backpack

also that person is calling localplayer and character for no reason, not to mention you can't call localplayer in a server script lol
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
12 Jul 2017 03:27 PM
show part of script where u insert val?
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 03:33 PM
Ahh yeah! I realized it was the PlayerGui that resetted! XD How do I fix that? I was thinking about doing this, but please if you know of any easier way I would be happy to know :D : game.Players.PlayerAdded:connect(function(Player) local ############### = script:Clone() duplisertScript.Parent = Player end) if game.Players.LocalPlayer.Humanoid.Health == 0 then game.Players.LocalPlayer.PlayerGui:WaitForChild("HUD") game.Players.LocalPlayer.PlayerGui.HUD.Rupees.TextButton.Text = game.Players.LocalPlayer.Amount.Value end
Report Abuse
LeafDoode is not online. LeafDoode
Joined: 29 May 2017
Total Posts: 3094
12 Jul 2017 03:34 PM
i never said put it in server script service .......
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
12 Jul 2017 03:36 PM
if your games filtering enabled you're gonna have to use game.Players.PlayerAdded in a server script, and the formatting + hashtags make that post hard to read. im assuming you're trying to insert a money value cuz rupees? if so just put a rupees value in the player instead of playergui and change the rupees gui text to that value whenever the val changes
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 03:50 PM
Nice, I'll just stick to a LocalScript inside the NumberValue. I'm completely new to ServerScriptService and all that.. do you guys know about some effective tutorials?
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
12 Jul 2017 03:59 PM
serverscriptservice is like a workspace for scripts. just put anything you need to happen on the server in it, and learn filteringenabled from wiki
Report Abuse
jugobag is online. jugobag
Joined: 23 Jun 2008
Total Posts: 1824
12 Jul 2017 03:59 PM
i like to turn off gui resetting and place any variables in there so it always sticks with them


Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:00 PM
game.Players.PlayerAdded:connect(function(Player)

local rupeeAmount = Instance.new("NumberValue", Player)
rupeeAmount.Name = "Amount"
rupeeAmount.Value = 0

end)

Whats wrong here? Its not adding the NumberValue to the player at all
Report Abuse
veryawesomeboy is not online. veryawesomeboy
Joined: 21 May 2013
Total Posts: 479
12 Jul 2017 04:00 PM
just add a folder to store the values, and name the values after the player name so you can distinguish between them.


Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:01 PM
jugobag how to turn off Gui resets?
Report Abuse
jugobag is online. jugobag
Joined: 23 Jun 2008
Total Posts: 1824
12 Jul 2017 04:01 PM
click on startergui and look in properties


Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:02 PM
Aaaah LOL that made it much more easier
Report Abuse
Wizzoblox02 is online. Wizzoblox02
Joined: 29 Dec 2015
Total Posts: 101
12 Jul 2017 04:21 PM
Probably a bit late, but I'm pretty sure it's because every time a player dies whatever is in the StarterPack is what the player spawns with. The reason for this is because whatever is in the StarterPack is not updated like whatever is in the player's file, wherever that may be.

So if you want to store a value somewhere, make sure it's not somewhere that resets upon a player's death.
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:28 PM
True, I found a way to do that, by storing all of the values inside a Folder. And each time a player joins, a clone of this LocalScript is placed inside the player, but it does not seem like working...:


game.Players.LocalPlayer.Folder.Amount.Value.Changed:connect(function()
game.Players.LocalPlayer.PlayerGui.HUD.Rupees.TextButton.Text = script.Parent.Folder.Amount.Value
end)
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:31 PM
The Gui won't update..
Report Abuse
Wizzoblox02 is online. Wizzoblox02
Joined: 29 Dec 2015
Total Posts: 101
12 Jul 2017 04:43 PM
game.Players.LocalPlayer.Folder.Amount.Changed:connect(function()
game.Players.LocalPlayer.PlayerGui.HUD.Rupees.TextButton.Text = script.Parent.Folder.Amount.Value
end)

the Changed function doesn't work for individual properties. So by getting rid of .Value it should now work :D
Report Abuse
cocoaboys is not online. cocoaboys
Joined: 08 Sep 2013
Total Posts: 488
12 Jul 2017 04:45 PM
Hmm I tried that, but then changed it to Value.. Doesn't work :/
Report Abuse
Wizzoblox02 is online. Wizzoblox02
Joined: 29 Dec 2015
Total Posts: 101
14 Jul 2017 11:00 PM
Sorry that I'm a bit late again, been busy past few days xD

Just a question, do you get any errors in the output, and if so what are they?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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