Do you all see any issues with my leveling system here? Any features that I’m missing?
local level = PlayerData2.Level
local xp = PlayerData2.XP
xp.Changed:connect(function()
local maxLevel = math.floor(((level.Value * 15) ^ 1.5))
if xp.Value>=maxLevel then
local rollover = (math.abs(xp.Value-maxLevel))
level.Value = level.Value + 1
xp.Value = rollover
end
end)
local level = PlayerData2.Level
local xp = PlayerData2.XP
xp.Changed:Connect(function()
local maxLevel = math.floor(((level.Value * 15) ^ 1.5))
if xp.Value >= maxLevel then
local rollover = xp.Value - maxLevel
level.Value += 1
xp.Value = rollover
end
end)
You were using the deprecated connection method “:connect()” instead of the current version “:Connect()”, as the previous post suggested level.Value = level.Value + 1 can become level.Value += 1 as both perform the same arithmetic operation and finally you don’t need to wrap the subtraction operation inside of a call to math.abs() as the first operand (value) is already checked to ensure that it is greater than the second operand (value) before the subtraction takes place, hence a negative value could never result from the subtraction.