I have a leaderboard with a leaderstat in it and then another "invisible" leaderboard with a leaderstat in it, credit is the invisible one and potatoes is the visible one. For some reason, if I change the credit to say 750, then it changes, and the potatoes one stays at say 740, but then when I leave and join the game the credit leaderstat has become 740. I don't know what is going on?
Visible leaderstat (Potatoes)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetGlobalDataStore("PotatoesSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Potatoes = Instance.new("IntValue",leader)
Potatoes.Name = "Potatoes"
Potatoes.Value = ds:GetAsync(player.UserId) or 0
ds:SetAsync(player.UserId, Potatoes.Value)
Potatoes.Changed:connect(function()
ds:SetAsync(player.UserId, Potatoes.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Potatoes.Value)
end)
Invisible leaderstat (Credit)
local DataStore = game:GetService("DataStoreService")
local ds2 = DataStore:GetGlobalDataStore("CreditSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader1 = Instance.new("Folder",player)
leader1.Name = "leaderstats1"
local Credit = Instance.new("IntValue",leader1)
Credit.Name = "Credit"
Credit.Value = ds2:GetAsync(player.UserId) or 0
ds2:SetAsync(player.UserId, Credit.Value)
Credit.Changed:connect(function()
ds2:SetAsync(player.UserId, Credit.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds2:SetAsync(player.UserId, player.leaderstats1.Credit.Value)
end)
Thanks!
