Oh! I see the problem, it doesn’t seem to break the loop I have another comma function if you would like to try it.
function comma(amount)
if (math.abs(amount) < 1000) then
return tostring(amount)
end
local str = (amount < 0 and "-" or "") .. tostring(math.abs(math.floor(amount))):reverse():gsub("%d%d%d","%1,"):gsub(",$",""):reverse()
if (not (amount == math.floor(amount))) then
str = str .. "." .. (tostring(amount):match("%d+.$"))
end
return str
end
You obviously don’t have to use it but try and replace it to see if it works
function comma(amount)
if (math.abs(amount) < 1000) then
return tostring(amount)
end
local str = (amount < 0 and "-" or "") .. tostring(math.abs(math.floor(amount))):reverse():gsub("%d%d%d","%1,"):gsub(",$",""):reverse()
if (not (amount == math.floor(amount))) then
str = str .. "." .. (tostring(amount):match("%d+.$")) -- here its underlined as a error
end
return str
end
Oh! I see the problem. I made a fixed version for you!
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerGui = Player:WaitForChild("PlayerGui")
local ScreenGui = PlayerGui:WaitForChild("ScreenGui")
local leaderstatAmounts = ScreenGui:WaitForChild("leaderstatAmounts")
local userDataFolder = ReplicatedStorage:WaitForChild("userData")
local userData = userDataFolder:FindFirstChild(Player.Name)
leaderstatAmounts.Credits.TextLabel.Text = "$"..Comma(userData.Credits.Value)
userData.Credits:GetPropertyChangedSignal("Value"):Connect(function()
leaderstatAmounts.Credits.TextLabel.Text = "$"..Comma(userData.Credits.Value)
end)
leaderstatAmounts.Miles.TextLabel.Text = ""..Comma(userData.StudsDriven.Value)
userData.StudsDriven:GetPropertyChangedSignal("Value"):Connect(function()
leaderstatAmounts.Miles.TextLabel.Text = ""..Comma(userData.StudsDriven.Value)
end)
The problem was that you did Credits.Value:GetPropertyChangedSignal, and that doesn’t work you have to remove the .Value because the value is returning a number.