local T=nil local z,b=pcall(function()T=(game:GetService("\068\097\116\097\083\116\111\114\101\083\101\114\118\105\099\101")):GetOrderedDataStore(DATA_STORE)end)if not z or T==nil then warn(b)script.Parent:Destroy()end local function W(T)T=T*60 local z=math.floor(T/86400)local b=math.floor(math.fmod(T,86400)/3600)local W=math.floor(math.fmod(T,3600)/60)return string.format("\037\048\050\100\100 \058 \037\048\050\100\104 \058 \037\048\050\100\109",z,b,W)end local J=function()if DO_DEBUG then print("\085\112\100\097\116\105\110\103 \098\111\097\114\100")end local z=(T:GetSortedAsync(false,10,1)):GetCurrentPage()for T,z in pairs(z)do local b=tonumber((string.split(z.key,NAME_OF_STAT))[2])local J=(game:GetService("\080\108\097\121\101\114\115")):GetNameFromUserIdAsync(b)local K=W(z.value)local I=scoreBlock.SurfaceGui I.Names["\078\097\109\101"..T].Text=J I.Score["\083\099\111\114\101"..T].Text=K I.Photos["\080\104\111\116\111"..T].Image=(game:GetService("\080\108\097\121\101\114\115")):GetUserThumbnailAsync(b,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size100x100)end if DO_DEBUG then print("\066\111\097\114\100 \117\112\100\097\116\101\100 \115\117\099\101\115\115\102\117\108\108\121")end end local K,I=pcall(J)if not K then warn(I)end
-- gets the datastore, fails if could not find
local Database = nil
local suc, err = pcall(function()
	Database = game:GetService("DataStoreService"):GetOrderedDataStore(DATA_STORE)
end)
if not suc or Database == nil then
	warn(err)
	script.Parent:Destroy()
end

local function disp__time(_time)
	_time = _time * 60
	local days = math.floor(_time / 86400)
	local hours = math.floor(math.fmod(_time, 86400) / 3600)
	local minutes = math.floor(math.fmod(_time, 3600) / 60)
	return string.format("%02dd : %02dh : %02dm", days, hours, minutes)
end

local UpdateBoard = function()
	if DO_DEBUG then
		print("Updating board")
	end
	local results = Database:GetSortedAsync(false, 10, 1):GetCurrentPage()
	for k, v in pairs(results) do
		local userid = tonumber(string.split(v.key, NAME_OF_STAT)[2])
		local name = game:GetService("Players"):GetNameFromUserIdAsync(userid)
		local score = disp__time(v.value)
		local sufgui = scoreBlock.SurfaceGui
		sufgui.Names["Name" .. k].Text = name
		sufgui.Score["Score" .. k].Text = score
		sufgui.Photos["Photo" .. k].Image =
			game:GetService("Players")
				:GetUserThumbnailAsync(userid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
	end
	if DO_DEBUG then
		print("Board updated sucessfully")
	end
end

local suc, err = pcall(UpdateBoard) -- update once
if not suc then
	warn(err)
end
