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)
endlocal 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 thenend 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 endend
endGetLBData()
while wait(60) do
pcall(function()
GetLBData()
end)
end