How to change numbers into UIListLayout Order

I’d like to create a script that would take a number as an argument and then return a set of letters that relate to the number.

Example:
You input 1, “AAA” Is the output.
You put 2, “AAB” Is the output.
You put 89, “ACK” Is the output.

I do not want the input 1 to return just “A”, I need it to return “AAA”.

Anyway I should go about doing this?

I dont fully understand your question. I understand why 1 would equal AAA and 2 would equal AAB, but why would 89 equal ACK?

1 Like

Because 26 is contained multiple times within 89.

1 Like

Nevermind, Im gonna let some GUI Pro figure it out, all I do is scripting and I never understood GUI much anyway.

1 Like

Well, here’s what I got, it’s 1 off. (Also, it should be ADK for 89)

local chars = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

function convertTo3Chars(num: number)
	local third = chars[num % 26 + 1]
	num = math.floor(num / 26)
	local second = chars[num % 26 + 1]
	num = math.floor(num / 26)
	local first = chars[num % 26 + 1]
	return first .. second .. third
end
2 Likes

This works entirely. Thank you very much for the help!

I just figured out a new way of doing it using your wonderful math and logic. Simply put, this removes nearly all restrictions (Excluding Roblox’s float number limit)

local LetterChars = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}

function ConvertNumToChars(num,Characters)
    num = tonumber(num) or 1 --To make sure that the number inputted is a number.
    Characters = Characters or 3 --Making sure there's a specified number of characters wanted.

    local Str = ""

    for i=1,Characters do
        local Letter = LetterChars[num % 26 + 1]
        Str = Letter..Str
        num = math.floor(num / 26)
    end

    return Str
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.