How do i format this script? Im trying to but it’s not working
local player = game.Players.LocalPlayer
local CurrentExp = player:WaitForChild("leaderstats").Exp
local MaxExp = player:WaitForChild("leaderstats").ExpToLevel
local Gui = script.Parent
local Exterior = Gui:WaitForChild("BackFrame")
local label = Gui:WaitForChild("TextLabel")
local Bar = Gui:WaitForChild("Expbar")
local suffixes = {'','K','M','B','T','Qd','Qn'}
local replicatedStorage = game:GetService("ReplicatedStorage")
local function format(val)
for i=1, #suffixes do
if tonumber(val) < 10^(i*3) then
return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
end
end
end
script.Parent.TextLabel.Text = format(CurrentExp.Value).."/"..format(MaxExp.Value) --This part isn't working
CurrentExp.Changed:Connect(function()
script.Parent.TextLabel.Text = CurrentExp.Value.."/"..MaxExp.Value
if CurrentExp.Value >= MaxExp.Value then
Bar.Size = UDim2.new(CurrentExp.Value/MaxExp.Value,0,1,0)
wait(0.5)
CurrentExp.Value = 0
Bar.Size = UDim2.new(CurrentExp.Value/MaxExp.Value,0,1,0)
else
Bar.Size = UDim2.new(CurrentExp.Value/MaxExp.Value,0,1,0)
end
end)
It think it’s best if you follow along this tutorial that uses a way to do suffixs/abbreviations. It should work for your thing too regardless if it was made for currency
It’s because you’re directly copying from the tutorial instead of seeing what you should do, at the end it shows him converting it into a module script for easy use you can use that and just use the ModuleScript’s function to abbreviate
It’s the simplest one I could find, he explains it quite simply, maybe try watching the full video first without copying any code to understand the process
He used the number thing as an example, you don’t have to take that part of the tutorial, you use your own number variables, aka, CurrentExp.Value and MaxExp.Value
I’m not sure if this will fix it or not. But since all text in a textlabel is a string, try using tostring(CurrentExp.Value), and tostring(MapExp.Value).