So I have a LeaderBoard that won't work and I don't get told why it won't work in the Developer Panel I don't exactly know why. What exactly could be going wrong?
---Script---
local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("myDataStore") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Value = DataStoreService:GetAsync(player.UserId) or 0 local data local success, errormessage = pcall(function() data = myDataStore:GetAsync(player.UserId.."-cash") end) if success then cash.Value = data else print("There was a error whilst getting your data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value) end) if success then print("Player Data successfully saved!") else print("There was a error when saving data") warn(errormessage) end end)
You forgot to set the Parent for your cash value like ForeverBrown stated. If you don't do it it won't be showing in the leaderboard.
Behind the if success then
if statement you can add cash.Parent = leaderstats
For Flowery
local DataStoreService = game:GetService("DataStoreService") local myDataStore = DataStoreService:GetDataStore("myDataStore") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local cash = Instance.new("IntValue") cash.Name = "Cash" cash.Parent = leaderstats cash.Value = 0 local data local success, errormessage = pcall(function() data = myDataStore:GetAsync(player.UserId.."-cash") end) if success then cash.Value = data else print("There was a error whilst getting your data") warn(errormessage) end end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value) end) if success then print("Player Data successfully saved!") else print("There was a error when saving data") warn(errormessage) end end)