Hello DevForum Community, I need help for my cash bar script it shows the cash number value but it shows past the decimal. Anyone have a solution for this? script below
function comma_value(n)
local left, num, right = string.match(n, ‘^([^%d]%d)(%d)(.-)$’)
return left … (num:reverse():gsub(’(%d%d%d)’, '%1 '):reverse()) … right
end
local leaderstats = player:WaitForChild(“leaderstats”)
local Cash = leaderstats:WaitForChild(“Money”)
if not Cash:IsA(“NumberValue”) and not Cash:IsA(“IntValue”) then
return
end
function UpdateCashTitle(value)
script.Parent.Text = “” … comma_value(value)
end
local player = game.Players.LocalPlayer
function comma_value(n)
local left, num, right = string.match(n, ‘^([^%d] *%d)(%d* )(.-)$’)
return left … (num:reverse():gsub(’(%d%d%d)’, '%1 '):reverse()) … right
end
local leaderstats = player:WaitForChild(“leaderstats”)
local Cash = leaderstats:WaitForChild(“Money”)
if not Cash:IsA(“NumberValue”) and not Cash:IsA(“IntValue”) then
return
end
function UpdateCashTitle(value)
script.Parent.Text = “” … comma_value(value)
end
UpdateCashTitle(Cash.Value)
Cash.Changed:Connect(function()
UpdateCashTitle(Cash.Value)
end)
btw I didn’t make any changes, only made it easier to read for others
So one of the options I can think of is using math.ceil or math.floor for your Cash Values.
math.floor meaning your value will round to the lower value whereas math.ceil will round it to the upper value e.g. math.floor(10.5) is equal to 10 whereas math.ceil(10.5) is equal to 11.
Let me know if UpdateCashTitle(math.floor(Cash.Value)) or UpdateCashTitle(math.ceil(Cash.Value)) works for you. Sorry if this was not what you were looking for, update me on how it goes though!