Help with Speedrun Leaderboard

Hi, i am trying to make a obby game with a speedrun system but I don’t know how to make a string leaderboard
The time is stored like this: image
I tried using tonumber() and string.sub()but didn’t work
PLS HELP

Code:

local sg = script.Parent
local sample = script:WaitForChild("Sample")
local sf = sg:WaitForChild("ScrollingFrame")
local ui = sf:WaitForChild("UI")

local dataStoreService = game:GetService("DataStoreService")
local dataStore = dataStoreService:GetOrderedDataStore("TimeLb")

wait(5)
while true do
    for i,plr in pairs(game.Players:GetChildren()) do
    	if plr.UserId>0 then
			local w = plr.Stats:WaitForChild("Best Time").Value
			if w then
    			pcall(function()
	    			dataStore:UpdateAsync(plr.UserId,function(oldVal)
	    				return tonumber(w)
    				end)
    			end)
    		end
    	end
	end

	local smallestFirst = true
	local numberToShow = 100
    local minValue = 1
    local maxValue = 10e30
    local pages = dataStore:GetSortedAsync(smallestFirst, numberToShow, minValue, maxValue)
	local top = pages:GetCurrentPage()

	local data = {}
	for a,b in ipairs(top) do
		local userid = b.key
    	local timee = b.value
    	local username = "[Failed To Load]"
    	local s,e = pcall(function()
	    	username = game.Players:GetNameFromUserIdAsync(userid)
	    end)
    	if not s then
	    	warn("Error getting name for "..userid..". Error: "..e)
	    end
	    local image = game.Players:GetUserThumbnailAsync(userid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size150x150)
		table.insert(data,{username,timee,image})
	end

	ui.Parent = script
	sf:ClearAllChildren()
	ui.Parent = sf
	for number,d in pairs(data) do
    	local name = d[1]
    	local val = d[2]
    	local image = d[3]
    	local color = Color3.new(1, 1, 1)
    	if number == 1 then
    		color = Color3.new(1,1,0)
    	elseif number == 2 then
    		color = Color3.new(0.470588, 0.470588, 0.470588)
    	elseif number == 3 then
    		color = Color3.fromRGB(170, 85, 0)
		end
		local new = sample:Clone()
		new.Name = name
		new.LayoutOrder = tonumber(number)
    	new.Image.Image = image
    	new.Image.Place.Text = "#"..number
		new.Image.Place.TextColor3 = color
    	new.PName.Text = name
		new.Value.Text = val
    	new.Value.TextColor3 = color
		new.PName.TextColor3 = color
    	new.Parent = sf
	end
    wait()
	sf.CanvasSize = UDim2.new(0,0,0,ui.AbsoluteContentSize.Y)
    wait(120)
end

This should help, considering 00:33.63 is a string, adding a string value to the leaderboard should work fine.

Sorry if this isn’t what you’re looking for, a tad bit confused on exactly what you are trying to get here.

1 Like

What do you mean by obby speedrun because I never heard of such thing like that.

1 Like

Hello,
search for toHMS converter it will basically display the number for example 10 as a 10 second etc.

Example:

local function toHMS(s)
	return string.format("%02i:%02i:%02i", s/60^2, s/60%60, s%60)
end

print(toHMS(65)) --will give me output 1 minute and 5 seconds
1 Like

Are you like doing a specific system that the players chooses and they get teleport to the game?

1 Like

i am trying to make a global lederboard not a leaderstats but thanks for replying

its a tower of hell type game but with speedrun

how do i make it display milliseconds?

Like I said try to find another toHMS function :).

1 Like

I really don’t know much about leaderboards but I recommend you try and script the speedrun template leaderboard or get the template and go into the scripts hope it helps.