So i have been trying to abbreviate leaderstat numbers containing decimals
for an example if the player so if the player has 5,2 money the player only gets 5 money is there a way to do this
So i have been trying to abbreviate leaderstat numbers containing decimals
for an example if the player so if the player has 5,2 money the player only gets 5 money is there a way to do this
Is math.floor
what you’re looking for? (based on the 2nd sentence)
print(math.floor(5.2)) --> 5
Or you’re looking for converting 1000 to 1K? (based on the title)
If you’re looking to get rid of the point(.) such as 5.4 cash then you would go with @Blockzez suggestion using math.floor()
Although if you’re tryingto get rid of a decimal(,) as in 1,100 cash or 151,314 cash then it’ll be a bit more computation.
if cash.Value >= 1000 and cash.Value < 1000000 then
local AbbreviatedValue = tostring(math.floor(cash.Value/1000)).."K"
elseif cash.Value >= 1000000 and cash.Value < 1000000000 then
local AbbreviatedValue = tostring(math.floor(cash.Value/1000000)).."M"
end
Then you can just keep with that method until you reach however many values you want such as Billion, Trillion, Quadrillion, Quintilian, etc