Leaderboard to leaderstat

How would I turn this leaderboard script into a leaderstat that shows the players best time?

local DataVer = “121”

for i,v in pairs(game.Players:GetPlayers()) do
game:GetService(“TeleportService”):Teleport(6078492585,v)
end

local DataStoreService = game:GetService(“DataStoreService”)
local Store = DataStoreService:GetOrderedDataStore(DataVer..“LeaderBoardData”)
local RationalDigits = 2
function GetLBData()
local success, pages = pcall(function()
return Store:GetSortedAsync(true, 10)
end)

if success and pages then
local data = pages:GetCurrentPage()
local a = 0
for _, entry in pairs(data) do
a = a + 1
if a == 1 then

  	end
  	local val = entry.value / 1000
  	local Addons={}
  	for t=1,RationalDigits do
  		local i = t-1
  		local integer,predecimal = math.modf(val*(10^i))
  		local decimal = predecimal/(10^i)
  		if decimal == 0 then
  			Addons[t] = "0"
  		end

  	end
  	local NewText = tostring(val)
  	for i,v in pairs(Addons) do
  		NewText = NewText..v
  	end
  	script.Parent.SurfaceGui["A" .. tostring(a)].PlrName.Text = entry.key .. ": " .. NewText
  end

end
end

GetLBData()

while wait(60) do
pcall(function()
GetLBData()
end)
end

Wdym by Leaderboard to leaderstat?

I want the script to show the players best time as a leaderstat.

You can use

game.Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player 

to create a leaderstats
then you parent your value to leaderstats and it should work.