So this is so weird, I change my datastore name since I decided to use different data for my scores. For some reason now I can't get an ordered list for my leaderboard.
The player loads the save data just fine and it displays on the in-game leaderboard but GetOrderedDataStore won't grab anything. If I change the db name to the old one the code works just fine.
I feel I am missing a step or procedure but can't figure it out.
serverscriptservice - script file
local DataStore = game:GetService("DataStoreService") local GameDB = DataStore:GetOrderedDataStore("TowersDB_Beta") --Data Store --local GameDB = DataStore:GetOrderedDataStore("RoomODS") --Data Store local function Handler() local Success, Err = pcall(function() --server connection error handling local Data = GameDB:GetSortedAsync(false, 5) --get the data from datastore(not ascending, 10 results) local RoomPage = Data:GetCurrentPage() --get results we created ----->>>>>TODO<<<<<---change to a find command instead of a direct link, might need unique name local frameContainer = workspace.Leaderboard.SurfaceGui.Frame:GetChildren() --visual gui spaces for leaderboard names print("leaderboard") for Rank, Data in ipairs(RoomPage) do --loop through player info local Name = Data.key --player name local Wins = Data.value --player score print(Name .. ":: " .. Wins) --write values to leaderboard gui frameContainer[Rank].Player.Text = Name frameContainer[Rank].Points.Text = Wins end --print("leaderboard updated...") end) if not Success then error(Err) --if connection wasn't made show error end end Handler() --calls to update leaderboard gui as well
serverscriptservice - script file 2 (not all the code)
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("TowersDB_Beta") --get data stored game.Players.PlayerAdded:Connect(function(player) --when player is added print("new player...") local leader = Instance.new("Folder", player) --create leadstat folder inside player leader.Name = "leaderstats" --folder name predefined and CASESENSITIVE --------wins--------- local playerWins = Instance.new("IntValue", leader) --create int holder inside leaderstats folder playerWins.Name = "Wins" --int value name (will appear on screen leaderboard) playerWins.Value = ds:GetAsync(player.UserId) or 0 --get stored score for player, if no score use 0 print("player initialized...") playerWins.Changed:Connect(function() --when rooms int value is changed print("saving score..." .. playerWins.Value) ds:SetAsync(player.UserId, playerWins.Value) --update time end) end)
In the first script if I switch the commented db it works fine.