I tried to make a script which turns 1500 to 1.5k and 1500000 to 1.5 million
It works for 1.5k but does not work for 1.5 mil
local abbreivations = {
["T"] = 10^12,
["B"] = 10^9,
["M"] = 10^6,
["K"] = 10^3
}
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if tonumber(msg) ~= nil then
local chosenabrevation = nil
local number = 0
for i,v in pairs(abbreivations) do
print(i.." is "..v)
if tonumber(msg) > v then
chosenabrevation = i
number = tonumber(msg)/v
end
end
if chosenabrevation ~= nil then
print(number..chosenabrevation)
else
print(tonumber(msg))
end
end
end)
end)
-- Player chatted number 1500, printed as 1.5k
-- Player chatted number 1500000, printed as 1500K not as 1.5 mil
Please tell how to fix this