How would I go about making a advanced number box?

I am trying to make a more advanced number counter

I cannot figure out how I have tried a lot of stuff when I get over 1000 it adds a K at the end of it for 1k but instead it shows 1000k and the player doesn’t have one million. Is their anyway to achieve this with the script I have? (seen below)

I have tried DevForum and YouTube no luck :frowning:

I am making my clicker game but when I try to get to let’s say 5Million clicks it shows 5000000M and I cannot figure out how to make it show as 5M. This is a local script and I am using GUI’s (obviously)

local Player = game.Players.LocalPlayer
local clicks,rebirths = Player:WaitForChild("leaderstats"):WaitForChild("Clicks"),Player:WaitForChild("leaderstats"):WaitForChild("Ascends")
local clickAmt = Player:WaitForChild("ClickAmount")

--// GUI OBJECTS \\--
local clicksLabel = script.Parent:WaitForChild("ClicksFrame"):WaitForChild("ClicksLabel")
local clickButton = script.Parent:WaitForChild("ClickButton")

local numbers = {
	[1] = {
		"K",
		4,
	},
	[2] = {
		"M",
		8,
	},
	[3] = {
		"B",
		11
	},
	[4] = {
		"T",
		13
	}
}

index = 1
textending = ""

clickButton.Activated:Connect(function()
	clicks.Value += clickAmt.Value
	for ind, tableType in pairs(numbers) do
		if #tostring(clicksLabel.Text) >= tableType[2] then
			print("Now ready to add Letter at end of text!")
			print(tableType[1])
			textending = tableType[1]
			clicksLabel.Text = tostring(clicks.Value..tableType[1])
			index += 1
		else
			print("Not ready :(")
			clicksLabel.Text = tostring(clicks.Value..textending)
		end
	end
end)
local Player = game.Players.LocalPlayer
local clicks = Player:WaitForChild("leaderstats"):WaitForChild("Clicks")
local rebirths = Player:WaitForChild("leaderstats"):WaitForChild("Ascends")
local clickAmt = Player:WaitForChild("ClickAmount")
local text = nil

--// GUI OBJECTS \\--
local clicksLabel = script.Parent:WaitForChild("ClicksFrame"):WaitForChild("ClicksLabel")
local clickButton = script.Parent:WaitForChild("ClickButton")

clickButton.MouseButton1Click:Connect(function()
	clicks.Value += clickAmt.Value
	if clicks.Value >= 1000 then
		text = (clicks.Value / 1000).."K"
	elseif clicks.Value >= 1000000 then
		text = (clicks.Value / 1000000).."M"
	elseif clicks.Value >= 1000000000 then
		text = (clicks.Value / 1000000000).."B"
	elseif clicks.Value >= 1000000000000 then
		text = (clicks.Value / 1000000000000).."T"
	else
		text = clicks.Value
	end
	clicksLabel.Text = tostring(text)
end)
1 Like

This open source module should help