How to display the correct percentage in a TextLabel? 2

I’ve made a similar post here

But i am curious to know how to make a percentage display more accurate in a TextLabel (instead of just 100%, the text displays 100,00%)

Current Script

local plr = game.Players.LocalPlayer
local expBar = script.Parent.LvPanel.XPBarBG.BarHolder.Bar
local RushiesTxt = script.Parent.Background.Rushies.RushiesBackground.Rushies
local LvTxt = script.Parent.LvPanel.LvDisplay.CurrentLv
local MaxExpTxt = script.Parent.Background.BarBackground["Exp/MaxpExp"]

local Stats = plr:WaitForChild("PlayerStats")

local function UpdateLvText()
	MaxExpTxt.Text = tostring(math.floor((Stats.Exp.Value / Stats.MaxExp.Value ) * 100)).."%"
	LvTxt.Text = Stats.Level.Value
end

This is a really helpful page: Formatting and Converting Strings.

If you wanted to display a percent you could do something like this:

local perc = 0.91 --Let's say this is your percent (expressed as decimal)

print(string.format("%.2f%%", 100*perc))
--Output: 91.00%
1 Like

Thank you very much i didn’t knew that existed, as soon as i get home i’ll test it