I use this to format: function TimePlayedClass:_timeToString(_time)
print(_time)
local seconds = _time
local minutes = math.floor(seconds / 60)
local secs = math.floor(seconds % 60)
local ms = math.floor((seconds - math.floor(seconds)) * 1000)
return string.format("%02d:%02d:%03d", minutes, secs, ms)
end
#URGENT - I save my time as miliseconds but get random numbers back
1 messages · Page 1 of 1 (latest)
And I also use this to update my leaderboard: function TimePlayedClass:_updateBoard()
if self._doDebug then print("Updating board") end
local results
local suc, sortedPages = pcall(function()
return self._datastore:GetSortedAsync(true, 10, 1):GetCurrentPage() -- true = ascending
end)
if not suc or not sortedPages then
if self._doDebug then warn("Failed to retrieve top 10 with least time. Error:", sortedPages) end
return
end
results = sortedPages
local sufgui = self._scoreBlock.Leaderboard
self._scoreBlock.Credits.Enabled = true
self._scoreBlock.Leaderboard.Enabled = #results ~= 0
self._scoreBlock.NoDataFound.Enabled = #results == 0
self:_clearBoard()
for k, v in pairs(results) do
local key = v.key
local userid = tonumber(key) or 0
local name, thumbnail
if userid <= 0 then
name = "Studio Test Profile"
thumbnail = "rbxassetid://11569282129"
else
name = self:_getUsernameAsync(userid)
thumbnail = self:_getThumbnailAsync(userid)
end
local score = self:_timeToString(v.value)
if self._doDebug then
print(("Rank %d: %s (%s) — %.2f mins"):format(k, name, key, v.value))
end
self:_onPlayerScoreUpdate(userid, v.value)
sufgui.Names["Name" .. k].Visible = true
sufgui.Score["Score" .. k].Visible = true
sufgui.Photos["Photo" .. k].Visible = true
sufgui.Names["Name" .. k].Text = name
sufgui.Score["Score" .. k].Text = score
sufgui.Photos["Photo" .. k].Image = thumbnail
if k == 1 and self._dancingRigModule then
task.spawn(function()
self._dancingRigModule.SetRigHumanoidDescription(userid > 0 and userid or 1)
end)
end
end