This function I use is to change a string like 10M into a number like 10000000
_G.abbreviationValues = {
["K"] = 1000;
["M"] = 1000000;
["B"] = 1000000000;
["T"] = 1000000000000;
-- and so on... you can fill the rest in if you need to
};
_G.complicateNumber = function(str:string)
print(str)
if tonumber(str) then
return tonumber(str)
end
local number, abbreviation = str:match("^([%d.]+)(%a)$");
if number and abbreviation then
local value = _G.abbreviationValues[abbreviation:upper()];
if value then
return value * tonumber(number);
end
else
error("Invalid abbreviation:" .. str);
end
end
when i try to call it like
print(_G.complicateNumber("10m"))
it returns
This is all in a server script in serverscriptservice