-
What do you want to achieve?
Basically currency leaderboard -
What is the issue?
Too much decimals in value -
What solutions have you tried so far?
I tried search for some solutions but didnt saw anything that could help me.
Lb script:
local ds = game:GetService("DataStoreService")
local M = require(game.ReplicatedStorage:WaitForChild("ModuleScript"))
local blocksODS = ds:GetOrderedDataStore("CurrencyStats1")
local timeUntilReset = 60
local function update()
for i, plr in pairs(game.Players:GetPlayers()) do
blocksODS:SetAsync(plr.UserId, plr.Stats.TotalCurrency.Value)
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = blocksODS:GetSortedAsync(false, 25)
local blocksPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(blocksPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local blocks = dataStored.value
local template = script.Template:Clone()
template.Name = name .. "Leaderboard"
template.PlrNameTemplate.PlrName.Text = name
template.RankTemplate.Rank.Text = "#" .. rankInLB
template.CurrencyTemplate.Blocks.Text = M.ZeroTwoIsCute(blocks)
template.Parent = script.Parent
end
end)
end
while wait(1) do
update()
wait(60)
spawn(function()
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
if timeUntilReset == 0 then
timeUntilReset = 10
end
end)
end
Thank you guys for any solutions :)!