Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Values not saving on Leaderboard?

Asked by
Cinorch 10
8 years ago
01local data = game:GetService("DataStoreService"):GetDataStore("Saves")
02local data = game:GetService("DataStoreService"):GetDataStore("Gold")
03local settings={
04    groupid = 2903819
05}
06 
07game:GetService("Players").PlayerAdded:connect(function(player)
08    local key = "user_"..player.UserId 
09 
10    local leaderstats = Instance.new("Folder", player)
11    leaderstats.Name = "leaderstats"
12    local rank = Instance.new("StringValue", leaderstats)
13    rank.Name = "Rank"
14    rank.Value = player:GetRoleInGroup(settings["groupid"])
15    local GetPlayerSave = data:GetAsync("user_"..player.UserId)
View all 39 lines...

I want two things to save, Saves and Gold, both don't seem to work now despite it was working before when it had one value.

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

I believe solving this would need folders to save each player's storage, otherwise returning the 2 values as nil.

P.S. Why do you need a 'Saves' value?

EDIT: Requested a fix by the owner

01local data = game:GetService("DataStoreService"):GetDataStore("Saves")
02local data = game:GetService("DataStoreService"):GetDataStore("Gold")
03local settings={
04    groupid = 2903819
05}
06 
07game:GetService("Players").PlayerAdded:connect(function(player)
08    local key = "user_"..player.UserId 
09 
10    local leaderstats = Instance.new("Folder", player)
11    leaderstats.Name = "leaderstats"
12    local rank = Instance.new("StringValue", leaderstats)
13    rank.Name = "Rank"
14    rank.Value = player:GetRoleInGroup(settings["groupid"])
15    local GetPlayerSave = data:GetAsync("user_"..player.UserId)
View all 39 lines...
0
Just for example, also could you explain further by showing me via script of what I did wrong? It would help me a lot, thanks! Cinorch 10 — 8y
0
`local points = Instance.new("NumberValue", leaderstats) was doubled`, I believe, therefor it's been doubling. D_ctorScript 0 — 8y
0
Then how would I add a second value to the leaderboard stats in order for it to save? Cinorch 10 — 8y
0
Make a seperate variable for Line 16, instead of taking the name of Gold. D_ctorScript 0 — 8y
0
You think you could code it to show me? I really have a hard time understanding sometimes, I'm sorry! Cinorch 10 — 8y
Ad

Answer this question