You can write your topic however you want, but you need to answer these questions:
What i would like to achieve is figuring out why the text label is not updating when the leaderboard updates in the while loop. The problem i’m having is that the text label text is not updating based on the Player’s leaderstats it says it has updated but when it does it stays at 0 even though the leaderstats is at 5
What i have tried so far is debugging. Yes, i did look for soulutions on the developer forum
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local DataStoreService = game:GetService("DataStoreService")
local CoinsLeaderboard = DataStoreService:GetOrderedDataStore("CoinsDataStore")
local LeaderBoardHolder = workspace.leaderboard
local LeaderboardGui = LeaderBoardHolder.GlobalLeaderboard.Container.ScrollingFrame.PlayerLeaderboard
local Player_Avatar = LeaderboardGui.PlayerAvatar
local Player_Name = LeaderboardGui.PlayerName
local Player_Rank = LeaderboardGui.Rank
local Player_Coins = LeaderboardGui.CoinsCollected
local function UpdateCoinsLeaderboard()
local Sucess, ErrorMessage = pcall(function()
local StoredCoins = CoinsLeaderboard:GetSortedAsync(false, 3)
local CoinsPage = StoredCoins:GetCurrentPage()
for Rank, Data in ipairs(CoinsPage) do
local Player_Name = game.Players:GetNameFromUserIdAsync(tonumber(Data.key))
local Player_UserName = Player_Name
local Coins = Data.value
local ShowOnleaderboard = false
for i,v in ipairs(workspace.leaderboard.GlobalLeaderboard.FrameHolder:GetChildren()) do
if v.Player.Text == Player_UserName then
ShowOnleaderboard = true
if ShowOnleaderboard then
break
end
end
end
if Coins and ShowOnleaderboard == false then
local Player = game.Players:GetPlayers()
local NewLeaderboardUi = game.ReplicatedStorage.PlayerLeaderboard:Clone()
NewLeaderboardUi.PlayerName.Text = Player_UserName
NewLeaderboardUi.CoinsCollected.Text = Coins .. " Coins "
NewLeaderboardUi.Rank.Text = "#" .. Rank
NewLeaderboardUi.PlayerAvatar.Image = game.Players:GetUserThumbnailAsync(Data.key, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size48x48)
NewLeaderboardUi.Position = UDim2.new(0, 0, NewLeaderboardUi.Position.Y.Scale + (.08 * #workspace.leaderboard.GlobalLeaderboard.FrameHolder:GetChildren()),0)
NewLeaderboardUi.Parent = workspace.leaderboard.GlobalLeaderboard.FrameHolder --
end
end
end)
if not Sucess then
warn(ErrorMessage)
end
end
while task.wait(1) do
for _, Player in ipairs(game.Players:GetPlayers()) do
CoinsLeaderboard:SetAsync(Player.UserId, Player.leaderstats.Coins.Value)
end
for _, Frame in ipairs(game.Workspace.leaderboard.GlobalLeaderboard.FrameHolder:GetChildren()) do
Frame:Destroy()
end
UpdateCoinsLeaderboard()
print("Leaderboard has been updated")
task.wait(10)
end
Hello, everyone so i’m trying to make a global leaderboard that updates the player’s stats with there current leaderstats but the issue is that the text is not updating with the player’s current leaderstats and i’m not sure why this is happening does anyone know the reason this is happening thank you all for your help