zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 17 Mar 2016 03:07 AM |
-help me make a script to save the leaderstat "Value" in all players who leave the game?
All I got is...
||||||||||||||
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr) local ls = plr:WaitForChild("leaderstats") local lvl = ls:FindFirstChild("Level") lvl = ds:GetAsync("Level") end)
game.Players.PlayerRemoving:connect(function(plrr) ds:UpdateAsync("Level") end)
||||||||||||||
..and obviously, that didn't work. So what can I do?
|
|
|
| Report Abuse |
|
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
| |
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
| |
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
| |
|
lululukas
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1043 |
|
|
| 17 Mar 2016 07:50 PM |
you need a key with the playerId
key="Player-"..plr.userId
savedvalues=ds:GetAsync(key)
if savedvalues then
lvl.Value=savedvalues[1]
|
|
|
| Report Abuse |
|
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 17 Mar 2016 09:31 PM |
so I tried this...
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr) local ls = plr:WaitForChild("leaderstats") local lvl = ls:FindFirstChild("Level") lvl = ds:GetAsync("Level") local key="Player-"..plr.userId
local savedvalues=ds:GetAsync(key)
if savedvalues then
lvl.Value=savedvalues[1]
end game.Players.PlayerRemoving:connect(function(plrr) ds:SetAsync(key, plr.lvl.Value) end) end)
...but it didn't work. |
|
|
| Report Abuse |
|
|
lululukas
|
  |
| Joined: 23 Aug 2010 |
| Total Posts: 1043 |
|
|
| 17 Mar 2016 10:21 PM |
you need an else as well... Okay here, ill link you a video. The audio is out of sync but you don't really need the explanations if you can read the script.
https://www.youtube(dot)com/watch?v=VXcbZ2kurvk |
|
|
| Report Abuse |
|
|