So i was working on changing my money to showcase on the UI, and I decided to format it with commas, with a function that works.
Here is the function I used:
function MathModule.formatWithCommas(number)
local formatted = number
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if k == 0 then
break
end
end
return formatted
end
In my main script this is the problem, and I’ve gone through several print statements to figure it out. Here is what I obtained in the output:
5,000
5,000 string
false
5,000 5,000
false
5000 5,000
from this code:
local function updateCredits()
local formatted = MathUtil.formatWithCommas(creditsValue.Value)
print(formatted)
print(tostring(formatted), type(formatted))
creditsLabel.Text = formatted
print(creditsLabel.AutoLocalize)
print(creditsLabel.Text, formatted)
task.wait(0.1)
print(creditsLabel.AutoLocalize)
print(creditsLabel.Text,formatted)
end
this made no sense to me as I figured it was autolocalize, or the type being a number, but all of it should be just fine. It changes the text directly to 5000 instead of 5,000 automatically even when I set it differently. I do not set it anywhere else in my code, this is the only script here that even references the creditsLabel. It’s happening to my other label as well though. I’m not sure if this is a studio bug, or something else that I just don’t know.

