of     1   

Fraxinus_Sanctus
#170968359Thursday, August 13, 2015 2:52 AM GMT

-------Read the bottom of the script local DataStore = game:GetService("DataStoreService"):GetDataStore("DerfStore") game.Players.PlayerAdded:connect(function(player) local stats = Instances.new("IntValue", player) stats.Name = "leaderstats" local gold = Instances.new("IntValue", stats) gold.Name = "gold" local level = Instances.new("IntValue", stats) level.Name = "level" local EXP = Instances.new("IntValue", stats) EXP.Name = "Exp" local key = "player-"..player.userId local savedValues = DataStore:GetAsync(key) if savedValues == nil then --Save format: (Gold, level, exp) gold.value = savedValues(1) level.value = savedValues(2) EXP.value = savedValues(5) else local valuesToSave = {gold.value, level.value, EXP.value} DataStore:setAsync(key, valuesToSave) end end) -------for some reason the leaderboard doesnt appear in game, can someone help me out? Online dancing since 1337
Fraxinus_Sanctus
#170968501Thursday, August 13, 2015 2:53 AM GMT

Bump Online dancing since 1337
Fraxinus_Sanctus
#170968670Thursday, August 13, 2015 2:55 AM GMT

Bump[2] Online dancing since 1337
Fraxinus_Sanctus
#170968752Thursday, August 13, 2015 2:55 AM GMT

Bump[3] Online dancing since 1337
Fraxinus_Sanctus
#170968850Thursday, August 13, 2015 2:56 AM GMT

Bump[4] Online dancing since 1337
Fraxinus_Sanctus
#170969072Thursday, August 13, 2015 2:58 AM GMT

Bump[5] Online dancing since 1337
Fraxinus_Sanctus
#170969249Thursday, August 13, 2015 3:00 AM GMT

Bump[6] Online dancing since 1337
Fraxinus_Sanctus
#170969845Thursday, August 13, 2015 3:05 AM GMT

Bump[7] Online dancing since 1337
Karthon950
#170969982Thursday, August 13, 2015 3:06 AM GMT

I believe your leaderstats should be a model so it should be like this -Players --Player ---leaderstats(model) ----Gold ----Otherthinginleaderboard ----Cash ----Otherthinginleaderboard2
Karthon950
#170970053Thursday, August 13, 2015 3:07 AM GMT

So change this... local stats = Instances.new("IntValue", player) stats.Name = "leaderstats" to this.... local stats = Instances.new("Model", player) stats.Name = "leaderstats"
instawin
#170970316Thursday, August 13, 2015 3:09 AM GMT

there's some things that are wrong: you misspelled the Instance table, it is Instance.new(classname, parent), not Instances.new(classname, parent) methods are case sensitive (eg: not :setAsync(key, val) but :SetAsync(key, val)) you used the wrong brackets to index from a table, use these: [ ] properties are case sensitive (eg: not .value, but .Value) your script wasn't saving data when you left why were you trying to set the values of your stats to values of your savedValues table, if savedValues is nil? and you may want to use game.OnClose for saving data when the player leaves local DataStore = game:GetService("DataStoreService"):GetDataStore("DerfStore") game.Players.PlayerAdded:connect(function(player) local stats = Instance.new("Folder", player) stats.Name = "leaderstats" local gold = Instance.new("IntValue", stats) gold.Name = "gold" local level = Instance.new("IntValue", stats) level.Name = "level" local EXP = Instance.new("IntValue", stats) EXP.Name = "Exp" local key = "player-"..player.userId local savedValues = DataStore:GetAsync(key) if savedValues then --Save format: (Gold, level, exp) gold.Value = savedValues[1] level.Value = savedValues[2] EXP.Value = savedValues[3] else gold.Value = 0 level.Value = 0 EXP.Value = 0 end end) game.Players.PlayerRemoving:connect(function(plr) local key = "player-"..plr.userId local stats = plr:FindFirstChild("leaderstats") local gold = stats:FindFirstChild("Gold") local level = stats:FindFirstChild("Level") local EXP = stats:FindFirstChild("Exp") if stats and gold and level and EXP then dataStore:SetAsync(key, {gold.Value, level.Value, EXP.Value}) end end)
Fraxinus_Sanctus
#170970683Thursday, August 13, 2015 3:13 AM GMT

I realise that but wouldnt that only work IF the player left the game? for example (if I shut the game down for an update it wouldnt save the data) Online dancing since 1337
instawin
#170970780Thursday, August 13, 2015 3:14 AM GMT

yes, that is why i suggested using game.OnClose either way, your original script didn't even save data.
kritiki
#170970837Thursday, August 13, 2015 3:15 AM GMT

@OP would it be alright if i copied your script? i would give all credit to you to make sure if its gonna save data that is
instawin
#170970866Thursday, August 13, 2015 3:15 AM GMT

actually no, because .PlayerRemoving fires regardless, even if the game is shut down, or he loses connection. still, use game.OnClose
ShungTzu
#170971146Thursday, August 13, 2015 3:18 AM GMT

Try local key = ("player-"..tostring(player.userId) local savedValues = DataStore:GetAsync(key) if not savedValues then print('no savedValues') local valuesToSave = {}--gold.value, level.value, EXP.value valuesToSave['Gold']=gold.Value valuesToSave['Level']=level.Value valuesToSave['EXP']=EXP.Value DataStore:setAsync(key,valuesToSave) else print('values loaded from DataStore') gold.Value=savedValues.gold level.Value=savedValues.level EXP.Value=savedValues.EXP end , and use prints to troubleshoot your own stuff.
Fraxinus_Sanctus
#170972542Thursday, August 13, 2015 3:32 AM GMT

would this count as a "On leave save"? game.Players.PlayerRemoving:connect(function(player) local key = "player-"..player.userId --Save key: {Gold, level, exp} local valuesToSave = {players.leaderstats.gold.value, players.leaderstats.level.value, players.leaderstats.EXP.value, } DataStore:SetAsync(key, valueToSave) end) I came across one of peaspods videos and looked at it, not sure if its outdated but he used it in a separate script would it work? Online dancing since 1337
instawin
#170974327Thursday, August 13, 2015 3:49 AM GMT

my modified version of your script would work for the most part, but there could be some data loss depending if leaderstats doesn't exist when the player leaves use the game.OnClose callback http://wiki.roblox.com/index.php?title=API:Class/DataModel/OnClose peaspod's tutorial on datastores is still relevant.

    of     1