025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 26 Apr 2015 06:58 PM |
when I join:
first time - I enter and change my value from 0 to 9923 second time - I join and value is 9223 third time - I join and value is 0
PLEASE help me
local datastore = game:GetService("DataStoreService"):GetDataStore("pt");
game.Players.PlayerAdded:connect(function(player) if not datastore:GetAsync("Points"..player.userId) then set(player.Name, "0") else set(player.Name, tostring(datastore:GetAsync("Points"..player.userId))) end end)
game.Players.PlayerRemoving:connect(function(p) datastore:SetAsync("Points"..p.userId, p.PlayerGui.balance.pts.Value) end)
function set(player, amount) game.Players:FindFirstChild(player).PlayerGui.balance.Label.Text = "Points: "..tostring(amount) game.Players:FindFirstChild(player).PlayerGui.balance.pts.Value = "Points: "..tonumber(amount) end
|
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 26 Apr 2015 07:03 PM |
| You g0tta w8 4 dem datas 2 b redgy m8' |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 26 Apr 2015 07:05 PM |
I also tried this, got same output
local datastore = game:GetService("DataStoreService"):GetDataStore("dankememeduded"); local crash = true;
game.Players.PlayerAdded:connect(function(player) if not datastore:GetAsync("Points"..player.userId) then set(player.Name, "0") wait() crash = false else player.PlayerGui.balance:WaitForChild("pts"); set(player.Name, tostring(datastore:GetAsync("Points"..player.userId))) wait() crash = false end end)
game.Players.PlayerRemoving:connect(function(p) if not crash then datastore:SetAsync("Points"..p.userId, p.PlayerGui.balance.pts.Value) end end)
function set(player, amount) game.Players:FindFirstChild(player).PlayerGui.balance.Label.Text = "Points: "..tostring(amount) game.Players:FindFirstChild(player).PlayerGui.balance.pts.Value = "Points: "..tonumber(amount) end
game.OnClose = function() wait(1) end
|
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
| |
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
| |
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
| |
|
|
| 26 Apr 2015 07:25 PM |
local datastore = game:GetService("DataStoreService"):GetDataStore("pt");
game.Players.PlayerAdded:connect(function(player) plr.balance.whatever = datastore:GetAsync("Points"..player.userId) or 0 end)
game.Players.PlayerRemoving:connect(function(p) datastore:SetAsync("Points"..p.userId, p.PlayerGui.balance.pts.Value) end) |
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 26 Apr 2015 07:26 PM |
| Ok, tell me what you're trying to do. I'll make a script for you.. |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 26 Apr 2015 07:28 PM |
when the player joins, if the player has a save, their point total is updated to a numbervalue in playergui called 'pts'
when the player leaves, pts is saved in the datastore |
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 26 Apr 2015 07:40 PM |
Try this local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("Points") game.Players.PlayerAdded:connect(function(player) local key = "SavedPoints" .. player.userId local pts = player.PlayerGui.balance:WaitForChild("pts") -- Recheck the hierarchy local saved = ds:GetAsync(key) if saved then pts.Text = saved else pts.Text = "0" end end)
game.Player.PlayerRemoving:connect(function(player) local pts = player.PlayerGui.balance:WaitForChild("pts") -- Recheck the hierarchy local key = "SavedPoints" .. player.userId ds:SetAsync(key,tonumber(pts)) -- Converts the string to a number value end)
|
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 26 Apr 2015 07:46 PM |
| doesnt work va it said balance is not a valid member so I added waits and it says Player is not a valid member of DataModel |
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 26 Apr 2015 07:49 PM |
oopsie replace the last part with this ( I missed a "s") Also could you tell me how your gui is structured from what I'm getting its balance > pts
game.Players.PlayerRemoving:connect(function(player) local pts = player.PlayerGui.balance:WaitForChild("pts") -- Recheck the hierarchy local key = "SavedPoints" .. player.userId ds:SetAsync(key,tonumber(pts)) -- Converts the string to a number value end) |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 27 Apr 2015 04:50 PM |
>playergui >>balance >>>pts >>>Label
|
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 27 Apr 2015 05:19 PM |
| Is pts where the text shows up or Label?Change the parenting around.. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 27 Apr 2015 05:29 PM |
Check out the place in my blurb, it has a fine example.
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 27 Apr 2015 06:10 PM |
chim thanks
but that's a pretty big module, how do I edit it to my terms? |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 27 Apr 2015 06:13 PM |
what im trying to do again: a numbervalue called 'pts' is in the gui 'balance' in their playergui when they join im trying to load the data [if they have a save] to it and then when they leave it saves from the pts value
|
|
|
| Report Abuse |
|
|