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
 

how do you make a datastore script that saves leaderstats

Previous Thread :: Next Thread 
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
12 Jan 2015 11:34 PM
Show us what you have so far.
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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
reptiledude10 is not online. reptiledude10
Joined: 16 Mar 2012
Total Posts: 29235
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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
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 is not online. 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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
13 Jan 2015 12:43 AM
omg thank you

-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:||
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
13 Jan 2015 07:17 PM
k...
because the previous script wasnt working

-{cpmoderator12345}- ||:Conquerer of Role-Playing forum:|| ||:average scripter:||
Report Abuse
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
08 Feb 2015 11:35 AM
bamp
im trying strings now
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
08 Feb 2015 11:40 AM
Same concept
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