For some reason the script I made to have a counter GUI for their leaderstats creates unneeded decimals, which is makes it a long string of numbers which shouldn’t be there.
If anyone could help fix this that would be great.
local function Format(value, idp)
local ex = math.floor (math.log(math.max(1, math.abs(value)), 1000))
local abbrevs = abbrev [1 + ex] or ("e+"..ex)
local normal = math.floor (value * ((10 ^ idp) / (1000 ^ ex))) / (10 ^ idp)
return ("%"..idp.."f%s"):format(normal, abbrevs)
end
while wait() do
local player = game.Players.LocalPlayer
script.Parent.Text = Format(player.leaderstats.Kills.value,2)
end```
The format string follows the same rules as the printf family of standard C functions. The only differences are that the options/modifiers * , l , L , n , p , and h are not supported and that there is an extra option, q . The q option formats a string in a form suitable to be safely read back by the Lua interpreter: the string is written between double quotes, and all double quotes, newlines, embedded zeros, and backslashes in the string are correctly escaped when written.
- Lua 5.1 Reference Manual, string.format (formatstring, ···)