I was first using this script in a âWhile loopâ, the Level went crazy
Then used the âChangedâ function, and now its showing this msg which Iâve never seen in my life!!
Any help or suggestion will be much appreciatedđ¤
--// XP Level
local xp = status.XP
local xp_level = plr_levels.XP
local points = values.Points
local levelGui = game_gui.Level
local xpFill = levelGui.Bar.Cover.Fill
local max = xp_level.Value * 5
xp.Changed:Connect(function()
if xp.Value >= max then
xp.Value = 0
xp_level.Value += 1
points.Value += 1
module.statusEntry(record_gui, "Leveled Up!", makeup.Colors.Cash)
module.statusEntry(record_gui, "+1 Point", makeup.Colors.Cash)
end
levelGui.Num.Text = xp_level.Value
local x = ((xp.Value * 100) / max) / 100
xpFill:TweenSize(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .25)
end)
Your entering an infinite loop with the connection.
Everytime xp is changed itâs firing your :Connect function but the function itself it also changing the value of xp making the function fire again (and again and againâŚ)
Try this script, I made a variable that, when the same parameter is changed, changes and does not work again
--// XP Level
local xp = status.XP
local xp_level = plr_levels.XP
local points = values.Points
local levelGui = game_gui.Level
local xpFill = levelGui.Bar.Cover.Fill
local max = xp_level.Value * 5
local debounce = false
xp.Changed:Connect(function()
if debounce then debounce=false; return end
if xp.Value >= max then
debounce=true
xp.Value = 0
xp_level.Value += 1
points.Value += 1
module.statusEntry(record_gui, "Leveled Up!", makeup.Colors.Cash)
module.statusEntry(record_gui, "+1 Point", makeup.Colors.Cash)
end
levelGui.Num.Text = xp_level.Value
local x = ((xp.Value * 100) / max) / 100
xpFill:TweenSize(UDim2.new(x, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .25)
end)
One thing Iâve experimented is that, when I make two other values, and do the same thing with those, the error doesnât happen
--/ 1 (Errorrrrr)
local xp = values.Status.XP
local xp_level = plr_levels.XP
xp.Changed:Connect(function()
if xp.Value >= 5 then
xp.Value = 0
xp_level.Value += 1
end
end)
--/ 2 (Working perfectly)
local wood = status.Wood
local box = status.Box
wood.Changed:Connect(function()
if wood.Value >= 5 then
wood.Value = 0
box.Value += 1
end
end)