Leaderboard hasn't updated despite DataStores have been

In one of my games for the past couple of weeks, the in-game leaderboard has been stuck on specific times. However when I update my own time, it just stays.

image

This hasn’t been a problem ever. I haven’t touched the leaderboard.
Another problem which may be apart of the problem?
Attempting to save data in the command bar returns a malformed number error.

The script of the leaderboard seems perfectly fine and I have zero clue why it shouldn’t update

local DataStoreService = game:GetService("DataStoreService")
local CoinsLeaderboard = DataStoreService:GetOrderedDataStore("time_wasted")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = CoinsLeaderboard:GetSortedAsync(false, 50)
		local CoinsPage = Data:GetCurrentPage()
		for rank, data in ipairs(CoinsPage) do
			local userName = game:GetService("UserService"):GetUserInfosByUserIdsAsync({tonumber(data.key)})
			
			local Name = userName[1].Username
			
	--		print(Name)
			
			local DisplayName = userName[1].DisplayName

			
			local Coins = data.value

			local isOnLeaderboard = false
			for i, v in pairs(script.Parent.LeaderboardGui.Holder.ScrollingFrame:GetChildren()) do
				if v.player.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			
			if Coins and isOnLeaderboard == false then
				local newLBFrame = script:WaitForChild("template"):Clone()
				newLBFrame.player.Text = DisplayName.." (@"..Name..")"
				
				local hour = math.floor(Coins/60)
				local min = Coins - (hour*60)
				
				newLBFrame.time.Text = hour.."h "..min.."m"
				
				newLBFrame.rank.Text = "#"..rank
				
				
				
				newLBFrame.Position = UDim2.new(1, 0, 0.02 * (#game.Workspace.bus.destroy_upon_crash.LeaderBoard.scr.LeaderboardGui.Holder.ScrollingFrame:GetChildren()), 0)
				newLBFrame.Parent = script.Parent.LeaderboardGui.Holder.ScrollingFrame
				
				game:GetService("TweenService"):Create(newLBFrame, TweenInfo.new(0.5), {Position = UDim2.new(0, 0, 0.02 * (#game.Workspace.bus.destroy_upon_crash.LeaderBoard.scr.LeaderboardGui.Holder.ScrollingFrame:GetChildren() - 1), 0)}):Play()
				
				
				local ps, pe = pcall(function()
					local thumbType = Enum.ThumbnailType.HeadShot
					local thumbSize = Enum.ThumbnailSize.Size420x420
					local content, isReady = game.Players:GetUserThumbnailAsync(tonumber(data.key), thumbType, thumbSize)
					
					newLBFrame.plrPortrait.Image = content
				end)
				
			end
		end
	end)
	
	
	if not success then
		print(errorMessage)
	end
	
end

Any information would be helpful!

1 Like

malformed number error goes from 115592229.."TW" part, idk if it helps

1 Like

That’s the Datastore key, that shouldn’t be the problem at all since its worked in the past. Also the key is usually a string so idk

UPDATE: It is fixed!

The reason why it didn’t work is because I mixed up

DatastoreService:GetOrderedDataStore()

with

DatastoreService:GetDataStore()

THEY ARE TWO TOTALLY DIFFERENT DATASTORES!!
Even with the same datastore name.

Just leaving this incase anybody somehow suffers the same problem in the future.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.