|
| 12 Jan 2015 11:31 PM |
im a noob to DS. so i cant figure out how to save leaderstats
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 12 Jan 2015 11:34 PM |
| Show us what you have so far. |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2015 11:43 PM |
prepare to laugh like heck
local ds = game:GetService("DataStoreService"):GetDataStore("Level") game.Players.PlayerAdded:connect(function(plr) local leaderstats = Instance.new("Model", plr) leaderstats.Name = "leaderstats" local l = Instance.new("IntValue", leaderstats) l.Name = "Level" local key = tostring(plr.userId).."_level" if ds:GetAsync(key) ~= nil then ds:UpdateAsync(key, function(currentlevel) workspace.LevelTPer.Touched:wait() return currentlevel + 1; end) end end)
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2015 11:44 PM |
I still use old data persistence... I don't get the DS thing in the first place.
If life throws you lemons, then throw them back! If Chuck Norris throws you lemons, say, "Thank you!" |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2015 11:48 PM |
I need DS because im making a universe game... ggnore
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 13 Jan 2015 12:00 AM |
local ds = game:GetService("DataStoreService"):GetDataStore("Level")
game.Players.PlayerAdded:connect(function(plr) local l = Instance.new("IntValue", plr) l.Name = "leaderstats" local lvl = Instance.new("IntValue",l) lvl.Name = "Level" local key = tostring(plr.userId).."_level" local data = ds:GetAsync(key) or 0 lvl.Value = data end)
game.Players.PlayerRemoving:connect(function(plr) local key = tostring(plr.userId).."_level" local current = plr.leaderstats.Level local data = ds:GetAsync(key) if data then ds:UpdateAsync(key,function(old) return current.Value; end) else ds:SetAsync(key,current.Value) end end) |
|
|
| Report Abuse |
|
|
|
| 13 Jan 2015 12:43 AM |
omg thank you
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
|
| 13 Jan 2015 05:29 AM |
Data Persistence is terrible. Didn't you see the blog article on how they crashed it one day? I don't think the admins know what they're doing with that anymore :P
I have a DataStore leaderboard (not the global one, and not the OrdereredDataStore, the DataStore.) if you want a premade one, or one to learn from. |
|
|
| Report Abuse |
|
|
|
| 13 Jan 2015 07:17 PM |
k... because the previous script wasnt working
-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:|| |
|
|
| Report Abuse |
|
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|