{Reupload} Problem with Global Leaderboard not updating text label's string value

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

			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 -- 

	if not Sucess then

while task.wait(1) do

	for _, Player in ipairs(game.Players:GetPlayers()) do
		CoinsLeaderboard:SetAsync(Player.UserId, Player.leaderstats.Coins.Value)

	for _, Frame in ipairs(game.Workspace.leaderboard.GlobalLeaderboard.FrameHolder:GetChildren()) do

	print("Leaderboard has been updated")

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

Are you changing your value on the server or on the client?

I’m changing the value of the text from the server

No, not the text, I mean the actual leaderstats value.

Test the game with 2 player’s and see if the leaderstats are the same.

Yeah the leaderstats are being handled by the server, i have created a seprate script to handle the leaderstats and it’s a server script

No I understand that your leaderstats is created by the server. Let me be more specific. What a lot of people do when testing out their leaderstats is they press play, go into the player, go into the leaderstats folder, and then change a value. Which is not the correct way as that is changing it on the client. What you have to do is switch over to the server by clicking the computer-looking icon next to the play button and change the value there.

Now with me having explained it more, are you making the mistake of changing it on the client and not switching over to the server before doing so?

I’m not the one changing the leaderstats the server is changing the leaderstats value when i touch a button this server script increases the leaderstats value by 1

local Debounce = false
local SellButton = workspace:FindFirstChild("SellButton")

	if hit.Parent:FindFirstChild("Humanoid") and Debounce == false then
		Debounce = true
		if Debounce then
			print("Player touched the sell button")
			local Player = game.Players.LocalPlayer
			Player.leaderstats.Coins.Value += 1
			Debounce = false

Which is being handled by the client via starter character scripts
It’s done on the client because i did not want to have it change for all the clients

Okay so yeah you are changing the value on the client, so the issue is not your global leaderboard at all. Instead of how you’re doing it right now, you need to use a RemoteEvent to fire to the server so it changes the value there.

Also, a server script doesn’t inherently change something for every player in the game if you specify it not to. Like you could just change this script into a server script and if you do it correctly, it would still only change the value for person who touched it

If it’s being handled by the client on a localscript they won’t replicate to the server whatsoever. Unless you use remote events.

If you want it to only sell for the player who touched it, use a server script and do:

local Players = game:GetService("Players")


Thank you i changed the script from client to server script and it has changed the stats thank you all for your help :slight_smile: