Abbreviate leaderstat on gui help

Hello, so currently I just started making a simulator game and came across an issue. When I try to display my leaderstat it shows 20000 instead of 20k. I did some research and found out I need to make it Abbreviate or something along the lines. Im not sure how I would rewrite my code for that or if I even need to. I assume all I need to do is put a local script in the text label, get the leaderstat and abbreviate it. If you can respond to this topic, could you go into studio and try to find a way, then copy and paste the code. Next to the lines if you can put how and why your code works so I can better understand what it means. Thank you for reading this and have a great rest of your day!

Leaderstat


game.Players.PlayerAdded:Connect(function(Player)
	local Leaderstats = Instance.new("Folder")
	Leaderstats.Name = "leaderstats"
	Leaderstats.Parent = Player

	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Parent = Leaderstats

	local Strength = Instance.new("IntValue")
	Strength.Name = "Strength"
	Strength.Parent = Leaderstats
	
	local Rebirths = Instance.new("IntValue")
	Rebirths.Name = "Water"
	Rebirths.Parent = Leaderstats

	local CoinsData
	local StrengthData
	local RebirthsData

	local Success, ErrorMessage = pcall(function()
		CoinsData = DataStore:GetAsync(Player.UserId.."-CashData")
		StrengthData = DataStore:GetAsync(Player.UserId.."-PointsData")
		RebirthsData = DataStore:GetAsync(Player.UserId.."-RebirthsData")
	end)

	if not Success then
		print(ErrorMessage)
	end

	if CoinsData ~= nil then
		Coins.Value = CoinsData
	else
		Coins.Value = 0
	end

	if StrengthData ~= nil then
		Strength.Value = StrengthData
	else
		Strength.Value = 0
	end
	
	if RebirthsData ~= nil then
		Strength.Value = RebirthsData
	else
		Strength.Value = 0
	end
end)

game.Players.PlayerRemoving:Connect(function(Player)
	pcall(function()
		DataStore:SetAsync(Player.UserId.."-CashData", Player.leaderstats.Coins.Value)
		DataStore:SetAsync(Player.UserId.."-PointsData", Player.leaderstats.Strength.Value)
		DataStore:SetAsync(Player.UserId.."-RebirthsData", Player.leaderstats.Rebirths.Value)
	end)
end)```
1 Like

abbreviation example there but the thing is that it will only support numbers inside the table via if it only supports trillions then after 999T it will break so better write your abbreviate numbers everytime you write one add 3 i.e if K is 3 then the next value should be 6

Roblox automatically abbreviates values in the leaderstats when it can’t fit the whole number.

yeah but it will stop at some point

That’s weird for me it doesn’t. Could you try to put it on a gui text label and see if it still says 20M?

Well, roblox only automatically abbreviates values in leaderstats, not in textlabels

If you would like to abbreviate numbers in a custom GUI you will have to do that yourself. Number Abbreviation Is a great resource for that

I’m not that great with reading, could you describe a little more in how I would get the leaderstat number on the text label but make it abbreviated? or possibly send a model I can take a look at

after you hit 1 trillion, it will say 1,000B