Title is pretty self explanatory, i just want to know what is the mathematic method i need to use to turn this:
Into an accurate 0% ~ 100% text display
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 = Stats.Exp.Value .. "/" .. Stats.MaxExp.Value
LvTxt.Text = Stats.Level.Value
end
Convert the value to a decimal, then a percentage. Like 55%.
local function UpdateLvText()
local decimal = Stats.Exp.Value / Stats.MaxExp.Value --A number from 0-100
local percent = math.floor(decimal * 100) --A integer from 0 - 100
MaxExpTxt.Text = percent .. '%'
LvTxt.Text = Stats.Level.Value
end
And if you wanted to do something like 55% (110/200):
local function UpdateLvText()
local decimal = Stats.Exp.Value / Stats.MaxExp.Value
local percent = math.floor(decimal * 100)
MaxExpTxt.Text = percent .. '% (' .. Stats.Exp.Value .. "/" .. Stats.MaxExp.Value .. ')'
LvTxt.Text = Stats.Level.Value
end
Edit: Used Math instead of math, should be lowercase.