Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a leaderboard to display large numbers?

By large numbers, I mean numbers like 239 quintillion or 676 septillion, etc. I know I'm probably going to have to use string values like "239Qn" but I don't know how to exactly get around determining whether if it's a thousand, a million, a billion, and so on, and once I do that, how do I determine if it's in the ones, tens, or hundreds. I've tried this:

local index = {4, 5, 6}

game.Players.PlayerAdded:connect(function(plr)
	local cash = Instance.new("StringValue", plr)
	cash.Name = "cash"
	cash.Value = "0"
	cash.Changed:connect(function()
		if cash.Value:len() == index[1 or 2 or 3] then
			cash.Value = cash.Value:sub(1, 3).."k"
		end
	end)
end)

But it prints all in the hundreds place, and I don't think it's efficient either.

Not a request, simply asking how to get around it.

1 answer

✓ Accepted answer

This should work, but if it doesn't let me know and I'll fix it!

Description: Simple conversion to thousands, millions, and billions!

ConvertShort(num)
	local x = tostring(num)
	if #x>=10 then
		local important = (#x-9)
		return x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B+"
	elseif #x>= 7 then
		local important = (#x-6)
		return x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M+"
	elseif #x>=4 then
		return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
	else
		return num
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.