Global Leaderboard acting weird

Ok, so i have 2 global leaderboards which i’ve been using for more than 2 months now.
Recently one of them has started acting weird, but the other one is completely fine…
The board which is having problems actually doesn’t show the #1 Player On The List but it does for the other leaderboard.

here are some screenshots -:
The board which has having problems .
image

The Board which is completely fine.
image

I haven’t messed with any of their scripts.
The script -:

local DataStoreService = game:GetService("DataStoreService")
local KillsLeaderboard = DataStoreService:GetOrderedDataStore("KillsLeaderboard")
local function updateLeaderboard()
	local success, errorMessage = pcall (function()
		local Data = KillsLeaderboard:GetSortedAsync(false,30)
		local Killspage = Data:GetCurrentPage()
		for Rank, data in ipairs(Killspage) do
			if tonumber(data.key) > 0 then 
				local username = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
				local userid = data.key
				local Time = data.value
				if Rank == 1 then
					local npc = game.workspace:FindFirstChild("TKIllsWinner1")
					if npc then
						npc.One.Base.Ui.Plr.Text = username
						npc.UserId.Value  = userid
						npc.One.Base.Ui.Num.Text = Time.." TKills"
					end
				end
				if Rank == 2 then
					local npc = game.workspace:FindFirstChild("TKillsWinner2")
					if npc then
						npc.To.Base.Ui.Plr.Text = username
						npc.UserId.Value  = userid
						npc.To.Base.Ui.Num.Text = Time.." TKills"
					end
				end

				if Rank == 3 then
					local npc = game.workspace:FindFirstChild("TKillsWinner3")
					if npc then
						npc.Tree.Base.Ui.Plr.Text = username
						npc.UserId.Value  = userid
						npc.Tree.Base.Ui.Num.Text = Time.." TKills"
					end
				end



				local isOnLeaderboard = false
				for i, v in pairs(game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder:GetChildren()) do
					if v.Player.Text == username then
						isOnLeaderboard = true
						break
					end
				end

				if Time and isOnLeaderboard == false then
					local newLbFrame = game.ReplicatedStorage:WaitForChild("TKillsFrame"):Clone()
					newLbFrame.Player.Text = username
					newLbFrame.TKills.Text = Time.." TKills"
					newLbFrame.Rank.Text = "#"..Rank

					if newLbFrame.Rank.Text == "#1" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(255,174,0)
						newLbFrame.Player.Text = "👑"..username.."👑"
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(255, 174, 0)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(255, 174, 0)
					end
					if newLbFrame.Rank.Text == "#2" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
					end
					if newLbFrame.Rank.Text == "#3" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
					end
					newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (0.03 * #game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder:GetChildren()),1)
					newLbFrame.Parent = game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder
				end
			end
		end
	end)

	if not success then
		warn(errorMessage)
	end
end

while true do

	for _, player in pairs(game.Players:GetPlayers()) do
		KillsLeaderboard:SetAsync(player.UserId, player.TTime.Value)
	end

	for _, frame in pairs (game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder:GetChildren()) do
		frame:Destroy()
	end

	updateLeaderboard()

	wait(60)
end

The other one which is working fine has the same script just with changed values so it shows the other
currenncy or whatever you want to call it.

Also there are some more weird things with the broken board it is showing in accurate values for example i have 455 kills and it says 411 on the leaderboard i think my datastore of this value has been fried :sob:

kindly help me please… :sad:

PS: if there is ANYTHING you could think please tell me because i think my datastore of this value is fried.

1 Like

Before posting a topic in devforum, make sure you have debugged it yourself. Did you print Rank? Did you print Text? You ask in devforum if you don’t know anymore what to do or how to fix it. Of couse, we still answer topics like this, but it’s better if we have more information about the problem and what you have done.

did try everything the code is working fine The problem is that its showing inaccurate values and #1

Can you picture that you added the print and also the Output?

ik the reason of inaccurate vals because of broken datastores from oct 20 ill try to fix it but idk bout the no #1

alright hold on wait a minute please

here and
image

hmmm i saw that yea ok isnt printing…

This means that the condition hasn’t passed, could you do print(newLb.Frame.Rank.Text)?

image

If I understand it correctly, there is something going on with the condition for Time and isOnLeaderboard. Please print those values before the if statement.

image

i have no idea what goin on now… the time one works completely fine but the Kills is messed up…

and btw if ur confused with the variables the Time is the variable in the Kills too i dint change the name just the value lol

I asked that you print the variable Time and isOnLeaderboard before their if statement. So your code should look like:

                local isOnLeaderboard = false
				for i, v in pairs(game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder:GetChildren()) do
					if v.Player.Text == username then
						isOnLeaderboard = true
						break
					end
				end
                print(Time, isOnLeaderboard)
				if Time and isOnLeaderboard == false then
					local newLbFrame = game.ReplicatedStorage:WaitForChild("TKillsFrame"):Clone()
					newLbFrame.Player.Text = username
					newLbFrame.TKills.Text = Time.." TKills"
					newLbFrame.Rank.Text = "#"..Rank

					if newLbFrame.Rank.Text == "#1" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(255,174,0)
						newLbFrame.Player.Text = "👑"..username.."👑"
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(255, 174, 0)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(255, 174, 0)
					end
					if newLbFrame.Rank.Text == "#2" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(167, 167, 167)
					end
					if newLbFrame.Rank.Text == "#3" then
						newLbFrame.Player.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
						newLbFrame.Rank.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
						newLbFrame.TKills.BackgroundColor3 = Color3.fromRGB(235, 123, 18)
					end
					newLbFrame.Position = UDim2.new(0, 0, newLbFrame.Position.Y.Scale + (0.03 * #game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder:GetChildren()),1)
					newLbFrame.Parent = game.Workspace.KillsGlobalLeaderboard.Middle.Leaderboard.Holder
				end

ok so i did what u wanted now its showing the value, plus the isonleaderboard…
image

im actually suspicious with the inaccurate values because i think because of that only #1 not showing i found this post by roblox showing how can fix this but idk what to do…