So I am making a cash leaderboard with a Data store. Now when I test it, it doesn't work. It works before but now it doesn't. Here is the script:
-- Savable leaderboard?
local ds = game:GetService("DataStoreService"):GetDataStore("Cash1112")
game.Players.PlayerAdded:Connect(function(player)
local key = "cash-"..player.userId
local folder = Instance.new("Folder",player)
folder.Name = "leaderstats" -- Must be lowercase
local currency = Instance.new("IntValue",folder)
currency.Name = "Cash" -- Name of your currency
currency.Value = 0 -- Starting Cash
local save = ds:GetAsync(key)
if save then
currency.Value = save[1]
else
local tab = {currency.Value}
ds:SetAsync(key,tab)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local key = "cash-"..player.userId
local currency = player.leaderstats:FindFirstChild("Cash") -- Currency name. Must match with the top
local tab = {currency.Value}
ds:SetAsync(key,tab)
end)
Thanks.

3 comments
Have you tried print debugging it yet? It may be tedious, but works almost every time for me.
How to do that?
userId is deprecated mate, also are you going to make another tutorial where you use a Script instead of a LocalScript