有没有办法用我的排行榜修复这个错误?

Is there anyway to fix this Error with my Leaderboard?

当我的排行榜尝试更新时,我收到了这个错误。 502:API 服务拒绝了错误请求。已排序的数据存储类型的值格式无效。 参数名称:值 这是脚本:

local CoinsDS = game:GetService("DataStoreService"):GetOrderedDataStore("MoneyLeaderboard")
local suffixes = {'','K','M','B','T','qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'}
local function format(val)
    for i=1, #suffixes do
        if tonumber(val) < 10^(i*3) then
            return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
        end
    end
end

while true do
    for _,Player in pairs(game.Players:GetPlayers()) do
        local Leaderstats = Player:FindFirstChild("leaderstats")
        if Leaderstats then
            local coins = Leaderstats:FindFirstChild("CloudCoins")
            if coins then
                CoinsDS:SetAsync(Player.UserId, coins.Value)
            end
        end
    end
    local boards = workspace:WaitForChild("LeaderboardStuff")
    local sellected = boards:WaitForChild("ViewCoins")
    local Count = boards:WaitForChild("CountCoins")
    local Info = Count:WaitForChild("Info")
    for i,v in pairs(sellected:WaitForChild("GUI"):GetChildren()) do
        v:Destroy()
    end
    for _,v in pairs(boards:WaitForChild("TopCoins"):GetChildren()) do
        v:Destroy()
    end
    local Success, Err = pcall(function()
        local Data = CoinsDS:GetSortedAsync(false, 10)
        local LPage = Data:GetCurrentPage()
        for i, v in pairs(LPage) do
            if v.key ~= nil and tonumber(v.key) and tonumber(v.key) > 0 then
                local name = game:GetService("Players"):GetNameFromUserIdAsync(v.key)
                if name ~= nil then
                    local Val  = v.value
                    local NewObj = game.ServerStorage:WaitForChild("TemplateCoins"):Clone()
                    NewObj:WaitForChild("Player").Text = name
                    NewObj:WaitForChild("Coins").Text = format(Val) 
                    NewObj:WaitForChild("Stats").Text = i.."°"
                    NewObj:WaitForChild("PlayerIcon").Image = "https://www.roblox.com/headshot-thumbnail/image?userId="..(v.key).."&width=150&height=150&format=png"
                    local boards = workspace:WaitForChild("LeaderboardStuff")
                    local sellected = boards:WaitForChild("ViewCoins")
                    NewObj.Position = UDim2.new(0, 0, NewObj.Position.Y.Scale + (0.09 * #sellected:WaitForChild("GUI"):GetChildren()), 0)
                    NewObj.Parent = sellected:WaitForChild("GUI")
                end
            end
        end
    end)
    if not Success then
        error(Err)
    end
    for i=30,1,-1 do
        wait(1)
        Info:WaitForChild("UpdateTime").Text = "Update In("..i..")"
    end
    wait()
end

该值为数值。它的值为 44909800000000002968496892153981593868198948444510090605799389908923580416 或 44.9TVg.

我不太擅长这个,我可能是错的,但是,我相信您需要将 UserId 转换为字符串,所有 DataStore 键都必须是字符串,UserId returns 是一个 int。

抱歉,我刚刚检查了这个,但我找到了解决方案。基本上我压缩数字并将其保存到 Leader board DataStore 中:

local Coins = coins ~= 0 and math.floor(math.log(coins) / math.log(1.00000000000001)) or 0

然后当我循环遍历 DataStore 时,我将其解包为其原始编号:

Val = Val ~= 0 and (1.00000000000001^Val) or 0