Thanks for trying to help @BIULDERBRO
Here is the code that I created that is overcomplicated. (This was about a year ago)
local money = script.Parent
local coins = money.Coins
wait()
local function changed ()
money.Text = money.Coins.Value
if coins.Value > 9999 and coins.Value < 1000000 then
local number = money.Text
local characters = string.len(tostring(number))
local oldstring = ""
if characters > 4 then
local commanumber = math.floor((characters-1)/3)
local leftover = characters - commanumber*3
local beginstring = string.sub(tostring(number), 1, leftover)
oldstring = beginstring
local subtractnumber = 1
if leftover == 1 then
subtractnumber = 1
elseif leftover == 2 then
subtractnumber = 0
elseif leftover == 3 then
subtractnumber = -1
end
for i = 1,commanumber do
oldstring = oldstring..","..string.sub(tostring(number), i*3-subtractnumber, i*3-subtractnumber+2)
end
else
oldstring = tostring(number)
end
money.Text = oldstring
elseif coins.Value > 999999 and coins.Value < 1000000000 then
local finalstring
if coins.Value < 10000000 then
finalstring = string.sub(tostring(coins.Value), 1, 1).."."..string.sub(tostring(coins.Value), 2, 3)
elseif coins.Value > 9999999 and coins.Value < 100000000 then
finalstring = string.sub(tostring(coins.Value), 1, 2).."."..string.sub(tostring(coins.Value), 3, 3)
elseif coins.Value > 99999999 then
finalstring = string.sub(tostring(coins.Value), 1, 3)
end
if string.sub(finalstring, 4, 4) == "0" then
finalstring = string.sub(finalstring, 1, 3)
if string.sub(finalstring, 3, 3) == "0" or "." then
finalstring = string.sub(finalstring, 1, 2)
if string.sub(finalstring, 2, 2) == "." then
finalstring = string.sub(finalstring, 1, 1)
end
end
end
money.Text = finalstring.."M"
elseif coins.Value > 999999999 then
local finalstring
if coins.Value < 10000000000 then
finalstring = string.sub(tostring(coins.Value), 1, 1).."."..string.sub(tostring(coins.Value), 2, 3)
elseif coins.Value > 9999999999 and coins.Value < 100000000000 then
finalstring = string.sub(tostring(coins.Value), 1, 2).."."..string.sub(tostring(coins.Value), 3, 3)
elseif coins.Value > 99999999999 then
finalstring = string.sub(tostring(coins.Value), 1, string.len(tostring(coins.Value))-9)
end
if coins.Value < 100000000000 then
if string.sub(finalstring, 4, 4) == "0" then
finalstring = string.sub(finalstring, 1, 3)
if string.sub(finalstring, 3, 3) == "0" or "." then
finalstring = string.sub(finalstring, 1, 2)
if string.sub(finalstring, 2, 2) == "." then
finalstring = string.sub(finalstring, 1, 1)
end
end
end
end
money.Text = finalstring.."B"
end
end
changed()
coins.Changed:Connect(changed)
Maybe you could simplify this instead?