I’ve tested in studio and my leaderboard is showing but in game it is not. Here is the script and some images:
yes i do have api services on
local DataStoreService = game:GetService("DataStoreService")
local TrashDataStore = DataStoreService:GetDataStore("TrashDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Money"
money.Value = 0
money.Parent = leaderstats
local totaltrash = Instance.new("IntValue")
totaltrash.Name = "Trash"
totaltrash.Value = 0
totaltrash.Parent = leaderstats
local Backpack = Instance.new("IntValue")
Backpack.Name = "BackpackTrash"
Backpack.Value = 0
Backpack.Parent = leaderstats
local data
local sucess, errormessage = pcall(function()
data = TrashDataStore:GetAsync(player.UserId.."-Trash")
end)
if sucess then
totaltrash.Value = data
else
print("There was an error getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local sucess, errormessage = pcall(function()
TrashDataStore:SetAsync(player.UserId.."-Trash",player.leaderstats.Trash.Value)
end)
if sucess then
print("Data Successfully Saved!")
else
print("Error Saving Data.")
warn(errormessage)
end
end)
Game:
Studio: