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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 29 May 2017 |
| Total Posts: 3094 |
|
|
| 12 Jul 2017 03:23 PM |
| that's all i can think of. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 12 Jul 2017 03:27 PM |
| show part of script where u insert val? |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 29 May 2017 |
| Total Posts: 3094 |
|
|
| 12 Jul 2017 03:34 PM |
| i never said put it in server script service ....... |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 08 Sep 2013 |
| Total Posts: 488 |
|
|
| 12 Jul 2017 04:01 PM |
| jugobag how to turn off Gui resets? |
|
|
| Report Abuse |
|
|
jugobag
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 1824 |
|
|
| 12 Jul 2017 04:01 PM |
click on startergui and look in properties
|
|
|
| Report Abuse |
|
|
cocoaboys
|
  |
| Joined: 08 Sep 2013 |
| Total Posts: 488 |
|
|
| 12 Jul 2017 04:02 PM |
| Aaaah LOL that made it much more easier |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 08 Sep 2013 |
| Total Posts: 488 |
|
| |
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|