So, I have a battlepass script, it works kinda well, but there’s one issue. When I reach, level 2, for example it keeps the 100 XP that I needed for level 1. I want it to reset visually, but not entirely reset data for it. I wouldn’t want to change the value in my player entirely since, I store all the total XP on it.
local xp = game.Players.LocalPlayer.2024BattlepassXP.Value
local currentLvl = 0
local TotalXPNeeded = 100
local NextLvlXPNeeded = 100
print("Player is Level "..currentLvl..", has "..xp.." XP altogether.")
local function updateProgress()
script.Parent.View.ProgressBar.Progress.Size = UDim2.new(xp / NextLvlXPNeeded, 0, 1, 0)
script.Parent.View.ProgressBar.Level.Text = "Level "..(currentLvl + 1)..":"
script.Parent.View.ProgressBar.XP.Text = xp.."/"..NextLvlXPNeeded.." XP"
end
updateProgress()
if currentLvl == 0 then
--1
TotalXPNeeded = 100
NextLvlXPNeeded = 100
if xp >= TotalXPNeeded then
currentLvl += 1
--2
TotalXPNeeded = 250
NextLvlXPNeeded = 150
updateProgress()
if xp >= TotalXPNeeded then
currentLvl += 1
--3
TotalXPNeeded = 400
NextLvlXPNeeded = 150
updateProgress()
if xp >= TotalXPNeeded then
currentLvl += 1
--4
TotalXPNeeded = 600
NextLvlXPNeeded = 200
updateProgress()
if xp >= TotalXPNeeded then
currentLvl += 1
--5
TotalXPNeeded = 1000
NextLvlXPNeeded = 400
updateProgress()
--then it goes on until level 20...