Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Make Large Numbers Into Shorter Versions?? PLEASE HELP (Question Requestioned)

Asked by 3 years ago

Please do not repost your question after it has been closed.

I'm Trying To Figure Out How I would go about formatting a large number to the shorter version by appending 'K' or 'M' using Lua. Example:

1000 = 1K
1254 = 1.2K
1000000 = 1M
1200000 = 1.2M

I Already Have The Script Here But I Don't Know How To Continue It, Thanks. Script:

while wait(0.1) do
    if game.Players.LocalPlayer.leaderstats.Coins.Value > 1000 then
        local shortAmt = tostring(game.Players.LocalPlayer.leaderstats.Coins.Value / 1000) .. "K"
        script.Parent.Text = " " .. shortAmt
    else
        script.Parent.Text = " "..game.Players.LocalPlayer.leaderstats.Coins.Value
    end
end

For Example :

while wait(0.1) do
    if game.Players.LocalPlayer.leaderstats.Coins.Value > 1000 then
        local shortAmt = tostring(game.Players.LocalPlayer.leaderstats.Coins.Value / 1000) .. "K"
        script.Parent.Text = "        " .. shortAmt
    else
    local shortAmr = tostring(game.Players.LocalPlayer.leaderstats.Coins.Value / 1000000) .. "M"
        script.Parent.Text = "        " .. shortAmr
      game.Players.LocalPlayer.leaderstats.Coins.Value
    end
end
0
Please do not submit multiple questions regarding the same topic. Delete one or the other. Gey4Jesus69 2705 — 3y

Answer this question