So I have a saver but it wont work I think its not made for my leaderboard I'll put both below! Oh and the Leader-Board is working just the saving is not! |LeaderBoard Script!|

game.Players.PlayerAdded:connect(function(player)
     local leaderstats = Instance.new("Model")
     leaderstats.Name = "leaderstats"
     leaderstats.Parent = player
     
local money = Instance.new("IntValue")
      money.Name = "Deaths"
      money.Value = 0
      money.Parent = leaderstats
local money = Instance.new("IntValue")
      money.Name = "AllDeaths"
      money.Value = 0
      money.Parent = leaderstats
local money = Instance.new("IntValue")
      money.Name = "Coins"
      money.Value = 0
      money.Parent = leaderstats
local money = Instance.new("IntValue")
      money.Name = "Rebirths"
      money.Value = 0
      money.Parent = leaderstats
  end)

|My Stat saver!|

local DS = game:GetService("DataStoreService"):GetDataStore("SaveMyData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local savevalue = plr.leaderstats.Deaths
local savevalue2 = plr.leaderstats.AllDeaths
local savevalue3 = plr.leaderstats.Coins
local savevalue4 = plr.Rebirths


local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
    savevalue.Value = GetSaved[1]
    savevalue2.Value = GetSaved[2]
    savevalue3.Value = GetSaved[3]
    savevalue4.Value = GetSaved[4]
    
 else
    local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, savevalue4.Value}
    DS:GetAsync(plrkey, NumbersForSaving)
  end
end)

game.Players.PlayerRemoving:Connect(function(plr)
    DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Deaths.Value,  plr.leaderstats.AllDeaths.Value, plr.Coins.Value, plr.Rebirths.Value})
    BindToClose()
end)

1 comment

0

I want all of my stats saved so if there is a error I missed all of them.