I really have know idea of how to make this. The other people arent LISTING WHERE TO PUT IT.
Is it like: If i. Leaderstats.value = 1000 do text = "1k"
I really have know idea of how to make this. The other people arent LISTING WHERE TO PUT IT.
Is it like: If i. Leaderstats.value = 1000 do text = "1k"
Hey dude i don't know if this works anymore cause i used it a long time ago, but here give it a try:
local function comma_value(amount) -- Stolen from here http://lua-users.org/wiki/FormattingNumbers
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local function formatTokens(amount)
if game.Players.LocalPlayer.leaderstats.Tokens.Value > 100000000 then
return comma_value(amount/1000000).."M"
elseif game.Players.LocalPlayer.leaderstats.Tokens.Value >= 100000 then
return comma_value(amount/1000).."K"
else
return comma_value(amount)
end
end
local function refreshTokenText()
--[[if game.Players.LocalPlayer.leaderstats.Tokens.Value > 99999 and game.Players.LocalPlayer.leaderstats.Tokens.Value < 1000000 then
script.Parent.Text = comma_value(game.Players.LocalPlayer.leaderstats.Tokens.Value/100000) .."K"
end
if game.Players.LocalPlayer.leaderstats.Tokens.Value > 999999 then
script.Parent.Text = comma_value(game.Players.LocalPlayer.leaderstats.Tokens.Value/1000000) .."M"
end
if game.Players.LocalPlayer.leaderstats.Tokens.Value < 100000 then
script.Parent.Text = comma_value(game.Players.LocalPlayer.leaderstats.Tokens.Value)
end]]--
script.Parent.Text = formatTokens(game.Players.LocalPlayer.leaderstats.Tokens.Value)
end
repeat wait() until game.Players.LocalPlayer:FindFirstChild("leaderstats") and game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("Tokens")
refreshTokenText()
game.Players.LocalPlayer.leaderstats.Tokens.Changed:Connect(function()
refreshTokenText()
end)
Of course you need to change things inside, example as "Tokens" and other stuff."
if worked or helped please accept, comment if there's a problem.
btw this is a local script :D
Use WaitForChild. Also, why do you make a function solely to call another function with no new arguments in your Connect?
If you have a problem with my answer think about how you didn't post an answer if you didn't i wouldn't have to and this wouldn't happen, if you don't like my answer just post your own smh.
Thank you dude!
I didn't post a new answer and instead downvoted because that's the point of the downvote button
"downvote button" bruh like i said if you don't like something at least give a reason to it, i'm sayin if you don't like my answer then fliping answer yourself! no worries tho i see you! :D
Literally just check the lenght of the number and in case it has more than a number then just keep first numbers and add a "k"
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
Probably because you have not said where do you need it. We are not clairvoyants.
https://forum.scriptinghelpers.org/topic/990/how-to-format-numbers-like-miners-haven-does
Sadly "LocalPlayer" says 'nil' value