I've got a script that displays the player's level as"'Bounty". If they are level 1 - 999 then it will display level 1 as 1,000, 2 as 2,000, 3 as 3,000 etc. But I'm not sure how to show 1mil bounty when they are level 1000. Here is the script that I'm using:
wait(3) local Player = game.Players.LocalPlayer while true do wait() if Player.Stats.Pirate.Value == 1 and Player.Stats.Level.Value <= 999 then script.Parent.Text = "Bounty:"..Player.Stats.Level.Value..",000" end end
Thanks for reading!
An example from Desi...Let's take "250000" for example, if we use string.gsub("25000", "(%d%d%d)", "%1,") it will return 250,00 because it searches the string from left to right, so we have to reverse it.
string.reverse("25000"):gsub("(%d%d%d)", "%1,") will return "000,52" so we reverse it again to revert the process. string.reverse("25000"):gsub("(%d%d%d)", "%1,") :reverse() and that's it.
local function addComas(str) return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse() end print(addComas("250000000")) print(addComas("25000000"))