So I've been trying to make A Value like a cash from 1000 to 1K into a text button and I don't know how, now why I need it? To money display gui to make it shorter
Here my script :
while wait() do game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Cash:" .. game.Players.LocalPlayer.leaderstats.Cash.Value end
function sortText(num) local values = {{1000, "K+"}, {1000000, "M+"}, {1000000000, "B+"}} local str = "" if type(num) ~= "number" then num = tonumber(num) end for i = 1, #values do if num >= values[i][1] then str = (math.floor(num / values[i][1]))..values[i][2] end end return (num < 1000 and num or str) end
This should do the trick. You can add more if you'd like, but I doubt you'd need to go above a billion.
Don't forget to accept the answer if it is what you were looking for!
I'm not entirely sure on that, I've tried before to see if there was a better algorithm myself, but this is the best I can think of for Simple
local placeTables = {1000, 10000, 100000, 1000000} local placeLetter = { [placeTables[1, 3]] = "k"; [placeTables[4]] = m; }; local player = game:GetService("Players") local guiLabel = Player.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel local cashValue = Player.leaderstats.Cash.Value while guiLabel do if cashValue = placeTables[1,4] then for_,Letter in ipairs(placeLetter) do if cashValue == Letter then guiLabel.Text = "Cash: "..cashValue..Letter end end end end
There's a high probability this won't work;/