local TweenService = game:GetService("TweenService")
local ConfigurationXP = require(game:GetService("ReplicatedStorage").Configuration.XP)
local changeDatas = require(game:GetService("ReplicatedStorage").Modules.ChangeDataValue)
local player = game.Players.LocalPlayer
local debounce=false
local function calculBar()
if debounce then debounce=false; return end
if player.DS.Levels.Value == nil then
player.DS.Levels.Value = 0
end
if player.DS.Levels.Value then
if player.DS.EXP.Value >= ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] then
debounce=true
changeDatas.removeValue(player.DS.EXP, ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)])
changeDatas.addValue(player.DS.Levels, 1)
local calcul = ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] - player.DS.EXP.Value
TweenService:Create(script.Parent.Level.Bar, TweenInfo.new(0.5), {Size = UDim2.new(1 / calcul, 0, 1, 0)}):Play()
script.Parent.Level.Label.Text = "LEVEL " .. tostring(player.DS.Levels.Value) .. " · " .. tostring(player.DS.EXP.Value) .. " EXP"
end
end
end
calculBar()
player.DS.EXP:GetPropertyChangedSignal('Value'):Connect(calculBar)
your script is not working Alex, here is what I did to fix your:
local TweenService = game:GetService("TweenService")
local ConfigurationXP = require(game:GetService("ReplicatedStorage").Configuration.XP)
local changeDatas = require(game:GetService("ReplicatedStorage").Modules.ChangeDataValue)
local player = game.Players.LocalPlayer
local debounce = false
local function calculBar()
if debounce == false then
debounce = true
if player.DS.Levels.Value ~= nil then
player.DS.Levels.Value = 1
end
if player.DS.Levels.Value then
if player.DS.EXP.Value >= ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] then
changeDatas.removeValue(player.DS.EXP, ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)])
changeDatas.addValue(player.DS.Levels, 1)
local calcul = ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] - player.DS.EXP.Value
TweenService:Create(script.Parent.Level.Bar, TweenInfo.new(0.5), {Size = UDim2.new(1 / calcul, 0, 1, 0)}):Play()
script.Parent.Level.Label.Text = "LEVEL " .. tostring(player.DS.Levels.Value) .. " · " .. tostring(player.DS.EXP.Value) .. " EXP"
end
end
task.wait(0.5)
debounce = false
end
end
you could be a bit more specific. we can only help you if you help us understand what works and doesn’t work.
just saying “your script is not working” isn’t helping anyone
I think i know why your code doesn’t work, you put == nil, but it’s ~= nil, so what is not working @ValtryekRBLX is that it don’t remove the exp needed