You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
i want to abbbreviate every number and when it reaches 1,000T it turns into 1aa and 1ab and 1ac like idle miner
- What is the issue? Include screenshots / videos if possible!
when the abbreviation reached 1ac or higher it just turns into 1.eK
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
the script might be wrong
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
btw my mouse is broken so i cant select all the words…
script:1
local currencyfolder = game.ReplicatedStorage.GameData.Currencies
local Abbrev = require(game.ReplicatedStorage.Abbreviate)
while wait() do
script.Parent.Coin.Text = Abbrev.abbreviate(currencyfolder.Coins.Value)
script.Parent.DawnCoin.Text = Abbrev.abbreviate(currencyfolder.DawnCoins.Value)
script.Parent.DuskCoin.Text = Abbrev.abbreviate(currencyfolder.DuskCoins.Value)
script.Parent.FireCoin.Text = Abbrev.abbreviate(currencyfolder.FireCoin.Value)
script.Parent.IceCoin.Text = Abbrev.abbreviate(currencyfolder.IceCoins.Value)
script.Parent.SuperCash.Text = Abbrev.abbreviate(currencyfolder.SuperCash.Value)
end
my abbreviation module:
Note: the script wasent made by me
local module = {}
function module.abbreviate(number) -- number is the number that we will send when we are calling the function
local abbreviations = { -- now we need a dictionary for our abbreviations so we put the abbreviation first then the ammount of digits for example ['K'] = 4,
['K'] = 4,
['M'] = 7,
['B'] = 10,
['T'] = 13,
['aa'] = 16,
['ab'] = 19,
['ac'] = 22,
['ad'] = 24,
['ae'] = 27,
['af'] = 30,
['ag'] = 33,
['ah'] = 36,
['ai'] = 39,
['aj'] = 42,
['ak'] = 45,
['al'] = 48,
['am'] = 51,
['an'] = 54,
['ao'] = 57,
['ap'] = 60,
['aq'] = 63,
['ar'] = 66,
['as'] = 69,
['at'] = 72,
['au'] = 75,
['av'] = 78,
['aw'] = 81,
['ax'] = 84,
['ay'] = 87,
['az'] = 90,
['ba'] = 93,
['bb'] = 96,
['bc'] = 99,
}
local abbreviatedNumber = {} -- an empty table that we will fill after
local text = tostring(math.floor(number)) -- converting the number to a string (math.floor rounds the number)
if #text > 3 then -- checking if the number is big enough to be abbreviated
for i, abbreviation in pairs(abbreviations) do -- finding the abbreviation
if #text >= abbreviation and #text < (abbreviation + 3) then
for abbreviation in text:gmatch(".") do -- looping through the string
table.insert(abbreviatedNumber, abbreviation) -- inserting each digit of the number to the empty table
end
if #text == abbreviation then -- checking if the number of digits is equal to the abbreviation
return abbreviatedNumber[1]..'.'..abbreviatedNumber[2]..i -- we get the first digit and the second digit and we seperae them with a '.' then we add abbreviation for example 1.5K
elseif #text == (abbreviation + 1) then -- we check if the number has 1 more digit than the abbreviation like the number 15000
return abbreviatedNumber[1]..abbreviatedNumber[2]..i -- we connect the first and second digit like 15K (without the '.')
elseif #text == (abbreviation + 2) then -- we check if the number has 2 more digit than the abbreviation like the number 150000
return abbreviatedNumber[1]..abbreviatedNumber[2]..abbreviatedNumber[3]..i -- we get the first 3 digits of the number then we add the abbreviation
end
end
end
else
return text -- if we can't abbreviate the number we return it how it is.
end
end
return module
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.