#Help with Adding shortcuts for numbers in UI

14 messages · Page 1 of 1 (latest)

crimson root
#

I made a punching simulator UI and when the number goes over 1 000, 1 000 000 or more it adds zeros or "XXe + XX", I want to have shortcuts for the numbers like:
1 000 = k - thousand
1 000 000 = M - milion
1 000 000 000 = B - Bilion
1 000 000 000 000 = T - Trillion
1 000 000 000 000 000 = Qa - Quadrillion
and so on, This is my UI and my script, How can I do that the letters will display in the Strenght (Power) UI?

#

Help with Adding shortcuts for numbers in UI

sturdy knoll
#

That’s a little more complicated than it seems but you could int divide the value, then use table indexes to add a suffix

#

There’s also a dev made module

#

Forgot the name

crimson root
#

i tried this script and it worked:
local player = game.Players.LocalPlayer

-- Funkcia na formátovanie čísiel s príponami
local function formatNumber(value)
local absValue = math.abs(value)
if absValue >= 1e15 then
return string.format("%.2fQa", value / 1e15)
elseif absValue >= 1e12 then
return string.format("%.2fT", value / 1e12)
elseif absValue >= 1e9 then
return string.format("%.2fB", value / 1e9)
elseif absValue >= 1e6 then
return string.format("%.2fM", value / 1e6)
elseif absValue >= 1e3 then
return string.format("%.2fK", value / 1e3)
else
return tostring(value)
end
end

while wait() do
local powerValue = player.leaderstats.Power.Value
script.Parent.TextLabel.Text = formatNumber(powerValue)
end

worldly hatchBOT
#

studio** You are now Level 1! **studio

sturdy knoll
#
crimson root
#

it makes dots "."

#

But it is ok

sturdy knoll
#

It’s annoying to make changes with higher numbers