Hello, I am wondering if it is possible to add commas into a number value if no to a text label and how to add it. Thanks!
I do not think you are able to do this with Number Values. You can use a string value and turn the number value to the string value. For example:
Number Value = 1000000
String Value = 1,000,000 or 1M
May I have an example with a script? Because I didn’t quit get the concept if I had to script it my self.
It is very complicated and is for advanced scripters only. Even I would not be able to do this. Here is a script from a tycoon:
leaderboard script:
local PlayerStats = game.ServerStorage.PlayerMoney:FindFirstChild(newPlayer.Name)
if PlayerStats ~= nil then
if cash then
local Short = Settings.LeaderboardSettings.ShowShortCurrency
PlayerStats.Changed:connect(function()
if (Short) then
cash.Value = Settings:ConvertShort(PlayerStats.Value)
else
cash.Value = Settings:ConvertComma(PlayerStats.Value)
end
end)
end
end
module script (SETTINGS):
function module:ConvertComma(num)
local x = tostring(num)
if #x>=10 then
local important = (#x-9)
return x:sub(0,(important))…“,”…x:sub(important+1,important+3)…“,”…x:sub(important+4,important+6)…“,”…x:sub(important+7)
elseif #x>= 7 then
local important = (#x-6)
return x:sub(0,(important))…“,”…x:sub(important+1,important+3)…“,”…x:sub(important+4)
elseif #x>=4 then
return x:sub(0,(#x-3))…“,”…x:sub((#x-3)+1)
else
return num
end
end
function module:ConvertShort(Filter_Num)
local x = tostring(Filter_Num)
if #x>=10 then
local important = (#x-9)
return x:sub(0,(important)).."."..(x:sub(#x-7,(#x-7))).."B+"
elseif #x>=13 then
local important = (#x-12)
return x:sub(0,(important)).."."..(x:sub(#x-9,(#x-9))).."T+"
elseif #x>=16 then
local important = (#x-15)
return x:sub(0,(important)).."."..(x:sub(#x-11,(#x-11))).."Qa+"
elseif #x>= 7 then
local important = (#x-6)
return x:sub(0,(important)).."."..(x:sub(#x-5,(#x-5))).."M+"
elseif #x>=4 then
return x:sub(0,(#x-3)).."."..(x:sub(#x-2,(#x-2))).."K+"
else
return Filter_Num
end
end