How to round numbers to thousands, millions, millions and so on

Hello everyone! I came across a moment when the numbers in the Label are too many and they need to be rounded to thousands, millions, billions and so on.

(the main question)
How to make a rounding function up to thousands (and so on)

Here is the script(if of course you need it for):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
local remoteEvent = ReplicatedStorage:WaitForChild("GuiLoader"):WaitForChild("RemoteEventDislike")
local Dislikes = player:WaitForChild("leaderstats"):WaitForChild("Dislikes")
local Rebirths = player:WaitForChild("leaderstats"):WaitForChild("Rebirths")
local Button = player:WaitForChild("PlayerGui"):WaitForChild("DefoltClick"):WaitForChild("ClickButton")
local GuiDis = player:WaitForChild("PlayerGui"):WaitForChild("DefoltClick"):WaitForChild("Dislike")
local GuiMDis = player:WaitForChild("PlayerGui"):WaitForChild("DefoltClick"):WaitForChild("MultiDislike")



local function use ()
	wait(0.1)
	Dislikes.Value+= Rebirths.Value

end
	
    GuiDis.Text = Dislikes.Value
	GuiMDis.Text = "X"..Rebirths.Value


Button.Activated:Connect(use)
remoteEvent.OnClientEvent:Connect(use)
1 Like

Are you talking about make number abbreviations, if so I have a video on that!

3 Likes
local number = math.random(0, 3842837)
local text = nil

if number >= 1000000 then
    text = string.format("%.3fM", number / 1000000))
elseif number >= 1000 then
    text = string.format("%.3fK", number / 1000))
else
    text = string.format("%.3f", number))
end

print(text, number)
4 Likes