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

My leaderboard failing often in saving?

Asked by 5 years ago

I have a leaderboard which saves values. The problem for me is it often fails and ruins peoples data. Is there another leaderboard which would be better? Here is my leaderboard:

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("JumpPowerSaveSystem")--change all "JumpPower" to what value you want and keep doing it 
local ds2 = datastore:GetDataStore("RebirthsSaveSystem")--change all "Rebirths" to what value you want  and keep doing it
local ds3 = datastore:GetDataStore("GemsSaveSystem")--change all "Rebirths" to what value you want  and keep doing it

game.Players.PlayerAdded:connect(function(plr)
 local folder = Instance.new("Folder", plr)
 folder.Name = "leaderstats"
 local JumpPower = Instance.new("IntValue", folder)
 JumpPower.Name = "JumpPower"
 local Rebirths = Instance.new("IntValue", folder)
 Rebirths.Name = "Rebirths"
  local Gems = Instance.new("IntValue", folder)
 Gems.Name = "Gems"


 JumpPower.Value = ds1:GetAsync(plr.UserId) or 0
 ds1:SetAsync(plr.UserId, JumpPower.Value)

 Rebirths.Value = ds2:GetAsync(plr.UserId) or 0
 ds2:SetAsync(plr.UserId, Rebirths.Value)

 Gems.Value = ds3:GetAsync(plr.UserId) or 0
 ds3:SetAsync(plr.UserId, Gems.Value)
game.Players.PlayerRemoving:Connect(function(plr)
      ds1:SetAsync(plr.UserId, JumpPower.Value)
      ds2:SetAsync(plr.UserId, Rebirths.Value)
     ds3:SetAsync(plr.UserId, Gems.Value)
end)


end)

0
your PlayerRemoving event's function should NOT be inside your PlayerAdded event's function. just move lines 25-29 below line 32 Gey4Jesus69 2705 — 5y
0
But then it makes the values blue. CaptainD_veloper 290 — 5y
0
Let me try it, CaptainD_veloper 290 — 5y
0
obviously.. you'll have to find the leaderstats, ie: `local leaderstats = plr:FindFirstChild("leaderstats") local jumppower = leaderstats.JumpPower` etc Gey4Jesus69 2705 — 5y

Answer this question