Hello. I am currently making an overhead gui that displays a player’s total RAP (recent average price of collectibles) and I made a function to round the RAP when it is over 1000. Here is the code:
function RoundRAP(Value)
local RAPString = ""
if Value >= 1000000 then
RAPString = (tostring(math.ceil(Value/1000000)) .. "M")
return RAPString
elseif Value >= 1000 then
RAPString = (tostring(math.ceil(Value/1000)) .. "K")
return RAPString
elseif Value < 1000 then
RAPString = (tostring(Value))
return RAPString
end
end
The problem I had was that my function didn’t round the decimals, so there would be too many of them. I tried to fix that with math.ceil but the problem with math.ceil is that it does not give any decimals at all, and I want one. Is there a way to only keep 1 decimal in the number or to round the number, but keep the first decimal?