-
What do you want to achieve? I want to achieve a working global leaderboard for my game.
-
What is the issue? The global leaderboard runs with no errors, however, the board does not update the frame. I’m using Roblox’s Billboard from a model as the leaderboard display.
-
What solutions have you tried so far? I have tried looking for errors such as misspellings but could not find anything. The tutorial I followed closely for making this leaderboard is How to Make A Global Leaderboard in Roblox Studio - YouTube / I have read very similar posts to this on the DevForum but they do not seem of help as I am constantly rechecking.
I am just confused on why this is not updating directly to the leaderboard, as you can see at the bottom of the image it is printing a statement every time it updates the leaderboard.
Locations of scripts and frames:
leaderstats and the LeaderboardHandler - ServerScriptService
-- Entire script, again followed closely to TheDevKings tutorial on YouTube
local DataStoreService = game:GetService("DataStoreService")
local KillsLeaderboard = DataStoreService:GetOrderedDataStore("KillsLeaderboard")
local function updateLeaderboard()
local success, errorMessage = pcall(function()
local Data = KillsLeaderboard:GetSortedAsync(false, 5)
local KillsPage = Data:GetCurrentPage()
for Rank, data in ipairs(KillsPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local Kills = data.Value
local isOnLeaderboard = false
for i, v in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if Kills and isOnLeaderboard == false then
local newLeaderboardFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLeaderboardFrame.Player.Text = Name
newLeaderboardFrame.Kills.Text = Kills
newLeaderboardFrame.Rank.Text = ""..Rank
newLeaderboardFrame.Position = UDim2.new(0, 0, newLeaderboardFrame.Position.Y.Scale + (.08 * #game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()), 0)
newLeaderboardFrame.Parent = game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, Player in pairs(game.Players:GetPlayers()) do
KillsLeaderboard:SetAsync(Player.UserId, Player.leaderstats.Kills.Value)
end
for _, frame in pairs(game.Workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print("Updated")
wait(10)
end
Leaderstats script (partial script)
--//Kills leaderstats
local Kills = Instance.new("IntValue", leaderstats)
Kills.Name = "Kills"
Kills.Parent = leaderstats
Any help or feedback on possible errors to my code and or functionality improvements would be greatly appreciated. If you need other information please ask.