Scripting error roblox studio

So I made a global leaderboard before and it saved int values.it works pretty well.

now i added more to it. before it was seconds saving of game only.

example : saved 5 seconds of speed run of obby to deadwoodx
now i added mili seconds, like 5.1,5.2

it says data store cannot save doubles number.so i made it like plr.value *10 = 5.1 * 10 = 51 which is not a doubles number.and it should save, but it does not.

Here is the script:

local data1 = datastore:GetOrderedDataStore("NewTimeSaveService")

local function updateleaderboard()
    local success, errormessage = pcall(function()
        local data = data1:GetSortedAsync(true,25)
        local currentpage = data:GetCurrentPage()
        for i,v in ipairs(currentpage) do
            local plr = game.Players:GetNameFromUserIdAsync(tonumber(v.key))
            local name = plr
            local wins = v.value
            local rank = i
            local onleaderboard = false
            for i,v in pairs(game.Workspace.leaderboard.SurfaceGui.ScrollingFrame:GetChildren()) do
                if v.PlayerName.Text == name then
                    onleaderboard = true
                    break
                end
            end
            if wins and onleaderboard == false then
                local frameclone = game.ReplicatedStorage.LeaderboardFrame2:Clone()
                frameclone.PlayerName.Text = name
                frameclone.RankLabel.Text = "#"..rank
                local winsshower = wins
                frameclone.WinsLabel.Text = winsshower
                frameclone.Position = UDim2.new(0,0,frameclone.Position.Y.Scale + (.035 * #game.Workspace.leaderboard.SurfaceGui.ScrollingFrame:GetChildren()),0)
                frameclone.Parent = game.Workspace.leaderboard.SurfaceGui.ScrollingFrame
            end
        end
    end)
    if not success then
        print(errormessage)
    end
end

while true do
    for i,v in pairs(game.Players:GetPlayers()) do
        if v.leaderstats.Time1.Value ~= 0 then
            local valueofplr = v.leaderstats.Time1.Value*100
            print(valueofplr)
            wait(0.5)
            data1:SetAsync(v.UserId, valueofplr)
        end
    end
    for i,v in pairs(game.Workspace.leaderboard.SurfaceGui.ScrollingFrame:GetChildren()) do
        v:Destroy()
    end
    updateleaderboard()
    print("updated")
    wait(15)
end

And that is the script, it still say cannot save doubles number.even if its not a doubles number.

Use math.floor() to round the number down as there still might be a decimal.

1 Like

oh where should i use it?
in saving player value?

Yes, you would use math.floor() on valueofplr.

1 Like

woah it worked thank you.its working now

1 Like