I am working on a simulator game where your stats are abbreviated. I just have one problem. Yes, it works, but for some reason, when you go past above 99.9T, it starts glitching. It sometimes says 0.0QN or 9999999999999999999999K. I don’t know why it isn’t working, but I’ve tried everything! I changed from int value to number value, but I still get the same result! Here is what my abbreviation method looks like:
local data = game.ServerStorage.PlayerData
local abbreviations = {
K = 4,
M = 7,
B = 10,
T = 13,
Q = 16,
QN = 19,
S = 22,
SP = 25,
O = 28,
N = 31,
D = 34,
U = 37,
DD = 40,
TD = 43,
QD = 46,
QND = 49,
SD = 52,
SPD = 55,
OD = 58,
ND = 61,
VT = 64,
UVT = 67,
DVT = 70,
TVT = 73,
QVT = 76,
QNVT = 79,
SVT = 82,
SVPT = 85,
}
function ChangeValue(text, data, chosenAbbreviation)
if chosenAbbreviation ~= nil then
local digits = abbreviations[chosenAbbreviation]
local rounded = math.floor(data.Value / 10 ^ (digits - 2)) * 10 ^ (digits - 2)
text.Value = string.format("%.1f", rounded / 10 ^ (digits - 1)) … chosenAbbreviation
else
text.Value = data.Value
end
end
game.Players.PlayerAdded:Connect(function(player)
–// Data
local playerData = Instance.new(“Folder”, data)
local dataCash = Instance.new(“NumberValue”, playerData)
dataCash.Name = “Cash”
--// Leaderstats
local cash = Instance.new("StringValue", leaderstats)
cash.Name = "Cash"
--// Abbreviation
local chosenAbbreviation
while wait() do
local cashText = tostring(math.floor(dataCash.Value))
for abbreviation, digits in pairs(abbreviations) do
if #cashText >= digits and #cashText < (digits + 3) then
chosenAbbreviation = abbreviation
break
else
chosenAbbreviation = nil
end
end
ChangeValue(cash, dataCash, chosenCashAbbreviation)
end
end)
I’m not sure why this keeps working incorrectly. Please help me!